import*as e from"../../core/common/common.js";import*as t from"../../core/host/host.js";import*as r from"../../core/i18n/i18n.js";import*as i from"../../ui/legacy/components/source_frame/source_frame.js";import*as o from"../../ui/legacy/legacy.js";import*as n from"../../core/platform/platform.js";import*as s from"../../core/sdk/sdk.js";import*as a from"../../ui/legacy/components/data_grid/data_grid.js";import*as l from"../mobile_throttling/mobile_throttling.js";import*as d from"../settings/emulation/components/components.js";import*as c from"../../core/root/root.js";import*as h from"../../models/bindings/bindings.js";import*as u from"../../models/logs/logs.js";import*as p from"../../models/workspace/workspace.js";import*as g from"./forward/forward.js";import*as m from"../../ui/legacy/components/perf_ui/perf_ui.js";import*as w from"../../ui/legacy/components/utils/utils.js";import{iconDataForResourceType as v}from"../utils/utils.js";import*as k from"../../ui/components/icon_button/icon_button.js";import*as b from"../../ui/components/legacy_wrapper/legacy_wrapper.js";import*as f from"./components/components.js";import*as C from"../../ui/legacy/components/cookie_table/cookie_table.js";import*as S from"../../models/issues_manager/issues_manager.js";import*as T from"../../models/persistence/persistence.js";import*as y from"../../third_party/chromium/client-variations/client-variations.js";import*as x from"../sources/sources.js";import*as R from"../../ui/legacy/components/object_ui/object_ui.js";import*as I from"../../models/text_utils/text_utils.js";import*as q from"../../ui/lit-html/lit-html.js";import*as L from"../../ui/components/helpers/helpers.js";import*as F from"../../ui/components/data_grid/data_grid.js";import*as H from"../../models/har/har.js";import*as P from"../../ui/components/render_coordinator/render_coordinator.js";import*as E from"../../ui/legacy/theme_support/theme_support.js";import*as M from"../search/search.js";const U=new CSSStyleSheet;U.replaceSync(".panel.network .toolbar.binary-view-toolbar{border-top:1px solid var(--color-details-hairline);border-bottom:0;padding-left:5px}.binary-view-copied-text{opacity:100%}.binary-view-copied-text.fadeout{opacity:0%;transition:opacity 1s}\n/*# sourceURL=binaryResourceView.css */\n");const N={copiedAsBase:"Copied as `Base64`",hexViewer:"`Hex` Viewer",copiedAsHex:"Copied as `Hex`",copiedAsUtf:"Copied as `UTF-8`",binaryViewType:"Binary view type",copyToClipboard:"Copy to clipboard",copyAsBase:"Copy as `Base64`",copyAsHex:"Copy as `Hex`",copyAsUtf:"Copy as `UTF-8`"},A=r.i18n.registerUIStrings("panels/network/BinaryResourceView.ts",N),B=r.i18n.getLocalizedString.bind(void 0,A);class V extends o.Widget.VBox{binaryResourceViewFactory;toolbar;binaryViewObjects;binaryViewTypeSetting;binaryViewTypeCombobox;copiedText;addFadeoutSettimeoutId;lastView;constructor(t,n,s){super(),this.binaryResourceViewFactory=new i.BinaryResourceViewFactory.BinaryResourceViewFactory(t,n,s),this.toolbar=new o.Toolbar.Toolbar("binary-view-toolbar",this.element),this.binaryViewObjects=[new W("base64",r.i18n.lockedString("Base64"),B(N.copiedAsBase),this.binaryResourceViewFactory.createBase64View.bind(this.binaryResourceViewFactory),this.binaryResourceViewFactory.base64.bind(this.binaryResourceViewFactory)),new W("hex",B(N.hexViewer),B(N.copiedAsHex),this.binaryResourceViewFactory.createHexView.bind(this.binaryResourceViewFactory),this.binaryResourceViewFactory.hex.bind(this.binaryResourceViewFactory)),new W("utf8",r.i18n.lockedString("UTF-8"),B(N.copiedAsUtf),this.binaryResourceViewFactory.createUtf8View.bind(this.binaryResourceViewFactory),this.binaryResourceViewFactory.utf8.bind(this.binaryResourceViewFactory))],this.binaryViewTypeSetting=e.Settings.Settings.instance().createSetting("binaryViewType","hex"),this.binaryViewTypeCombobox=new o.Toolbar.ToolbarComboBox(this.binaryViewTypeChanged.bind(this),B(N.binaryViewType));for(const e of this.binaryViewObjects)this.binaryViewTypeCombobox.addOption(this.binaryViewTypeCombobox.createOption(e.label,e.type));this.toolbar.appendToolbarItem(this.binaryViewTypeCombobox);const a=new o.Toolbar.ToolbarButton(B(N.copyToClipboard),"copy");a.addEventListener(o.Toolbar.ToolbarButton.Events.Click,(e=>{this.copySelectedViewToClipboard()}),this),this.toolbar.appendToolbarItem(a),this.copiedText=new o.Toolbar.ToolbarText,this.copiedText.element.classList.add("binary-view-copied-text"),this.toolbar.element.appendChild(this.copiedText.element),this.addFadeoutSettimeoutId=null,this.lastView=null,this.updateView()}getCurrentViewObject(){const e=this.binaryViewObjects.find((e=>e.type===this.binaryViewTypeSetting.get()));return console.assert(Boolean(e),`No binary view found for binary view type found in setting 'binaryViewType': ${this.binaryViewTypeSetting.get()}`),e||null}async copySelectedViewToClipboard(){const e=this.getCurrentViewObject();e&&(t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText((await e.content()).content),this.copiedText.setText(e.copiedMessage),this.copiedText.element.classList.remove("fadeout"),this.addFadeoutSettimeoutId&&(clearTimeout(this.addFadeoutSettimeoutId),this.addFadeoutSettimeoutId=null),this.addFadeoutSettimeoutId=window.setTimeout(function(){this.copiedText.element.classList.add("fadeout")}.bind(this),2e3))}wasShown(){this.updateView(),this.registerCSSFiles([U])}updateView(){const e=this.getCurrentViewObject();if(!e)return;const t=e.getView();t!==this.lastView&&(this.lastView&&this.lastView.detach(),this.lastView=t,t.show(this.element,this.toolbar.element),this.binaryViewTypeCombobox.selectElement().value=this.binaryViewTypeSetting.get())}binaryViewTypeChanged(){const e=this.binaryViewTypeCombobox.selectedOption();if(!e)return;const t=e.value;this.binaryViewTypeSetting.get()!==t&&(this.binaryViewTypeSetting.set(t),this.updateView())}addCopyToContextMenu(e,r){const i=e.clipboardSection().appendSubMenuItem(r).footerSection();i.appendItem(B(N.copyAsBase),(async()=>{const e=await this.binaryResourceViewFactory.base64();t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e.content)})),i.appendItem(B(N.copyAsHex),(async()=>{const e=await this.binaryResourceViewFactory.hex();t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e.content)})),i.appendItem(B(N.copyAsUtf),(async()=>{const e=await this.binaryResourceViewFactory.utf8();t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e.content)}))}}class W{type;label;copiedMessage;content;createViewFn;view;constructor(e,t,r,i,o){this.type=e,this.label=t,this.copiedMessage=r,this.content=o,this.createViewFn=i,this.view=null}getView(){return this.view||(this.view=this.createViewFn()),this.view}}var O=Object.freeze({__proto__:null,BinaryResourceView:V,BinaryViewObject:W});const D=new CSSStyleSheet;D.replaceSync(".list{border:none!important;border-top:1px solid var(--color-details-hairline)!important}.blocking-disabled{opacity:80%}.editor-container{padding:0 4px}.no-blocked-urls,\n.blocked-urls{overflow-x:hidden;overflow-y:auto}.no-blocked-urls{display:flex;justify-content:center;padding:10px}.no-blocked-urls > span{white-space:pre}.blocked-url{display:flex;flex-direction:row;align-items:center;flex:auto}.blocked-url-count{flex:none;padding-right:9px}.blocked-url-checkbox{margin-left:8px;flex:none}.blocked-url-checkbox:focus{outline:auto 5px -webkit-focus-ring-color}.blocked-url-label{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex:auto;padding:0 3px}.blocked-url-edit-row{flex:none;display:flex;flex-direction:row;margin:7px 5px 0;align-items:center}.blocked-url-edit-value{user-select:none;flex:1 1 0}.blocked-url-edit-row input{width:100%;text-align:inherit;height:22px}\n/*# sourceURL=blockedURLsPane.css */\n");const G={enableNetworkRequestBlocking:"Enable network request blocking",addPattern:"Add pattern",removeAllPatterns:"Remove all patterns",addNetworkRequestBlockingPattern:"Add network request blocking pattern",networkRequestsAreNotBlockedS:"Network requests are not blocked. {PH1}",dBlocked:"{PH1} blocked",textPatternToBlockMatching:"Text pattern to block matching requests; use * for wildcard",patternInputCannotBeEmpty:"Pattern input cannot be empty.",patternAlreadyExists:"Pattern already exists.",itemDeleted:"Item successfully deleted"},z=r.i18n.registerUIStrings("panels/network/BlockedURLsPane.ts",G),_=r.i18n.getLocalizedString.bind(void 0,z);let j=null;class K extends o.Widget.VBox{manager;toolbar;enabledCheckbox;list;editor;blockedCountForUrl;updateThrottler;constructor(e){super(!0),this.manager=s.NetworkManager.MultitargetNetworkManager.instance(),this.manager.addEventListener(s.NetworkManager.MultitargetNetworkManager.Events.BlockedPatternsChanged,(()=>{this.update()}),this),this.toolbar=new o.Toolbar.Toolbar("",this.contentElement),this.enabledCheckbox=new o.Toolbar.ToolbarCheckbox(_(G.enableNetworkRequestBlocking),void 0,this.toggleEnabled.bind(this)),this.toolbar.appendToolbarItem(this.enabledCheckbox),this.toolbar.appendSeparator();const t=new o.Toolbar.ToolbarButton(_(G.addPattern),"plus");t.addEventListener(o.Toolbar.ToolbarButton.Events.Click,this.addButtonClicked,this),this.toolbar.appendToolbarItem(t);const r=new o.Toolbar.ToolbarButton(_(G.removeAllPatterns),"clear");r.addEventListener(o.Toolbar.ToolbarButton.Events.Click,this.removeAll,this),this.toolbar.appendToolbarItem(r),this.list=new o.ListWidget.ListWidget(this),this.list.element.classList.add("blocked-urls"),this.list.setEmptyPlaceholder(this.createEmptyPlaceholder()),this.list.show(this.contentElement),this.editor=null,this.blockedCountForUrl=new Map,s.TargetManager.TargetManager.instance().addModelListener(s.NetworkManager.NetworkManager,s.NetworkManager.Events.RequestFinished,this.onRequestFinished,this,{scoped:!0}),this.updateThrottler=e,this.update()}static instance(t){return j&&!t?.forceNew||(j=new K(t?.updateThrottler||new e.Throttler.Throttler(200))),j}createEmptyPlaceholder(){const e=this.contentElement.createChild("div","no-blocked-urls"),t=o.UIUtils.createTextButton(_(G.addPattern),this.addButtonClicked.bind(this),"add-button");return o.ARIAUtils.setLabel(t,_(G.addNetworkRequestBlockingPattern)),e.appendChild(r.i18n.getFormatLocalizedString(z,G.networkRequestsAreNotBlockedS,{PH1:t})),e}static reset(){j&&j.reset()}addButtonClicked(){this.manager.setBlockingEnabled(!0),this.list.addNewItem(0,{url:n.DevToolsPath.EmptyUrlString,enabled:!0})}renderItem(e,t){const r=this.blockedRequestsCount(e.url),i=document.createElement("div");i.classList.add("blocked-url");const o=i.createChild("input","blocked-url-checkbox");return o.type="checkbox",o.checked=e.enabled,o.disabled=!t,i.createChild("div","blocked-url-label").textContent=e.url,i.createChild("div","blocked-url-count").textContent=_(G.dBlocked,{PH1:r}),t&&(i.addEventListener("click",(t=>this.togglePattern(e,t))),o.addEventListener("click",(t=>this.togglePattern(e,t)))),i}togglePattern(e,t){t.consume(!0);const r=this.manager.blockedPatterns();r.splice(r.indexOf(e),1,{enabled:!e.enabled,url:e.url}),this.manager.setBlockedPatterns(r)}toggleEnabled(){this.manager.setBlockingEnabled(!this.manager.blockingEnabled()),this.update()}removeItemRequested(e,t){const r=this.manager.blockedPatterns();r.splice(t,1),this.manager.setBlockedPatterns(r),o.ARIAUtils.alert(G.itemDeleted)}beginEdit(e){return this.editor=this.createEditor(),this.editor.control("url").value=e.url,this.editor}commitEdit(e,t,r){const i=t.control("url").value,o=this.manager.blockedPatterns();r?o.push({enabled:!0,url:i}):o.splice(o.indexOf(e),1,{enabled:!0,url:i}),this.manager.setBlockedPatterns(o)}createEditor(){if(this.editor)return this.editor;const e=new o.ListWidget.Editor,t=e.contentElement();t.createChild("div","blocked-url-edit-row").createChild("div").textContent=_(G.textPatternToBlockMatching);const r=t.createChild("div","blocked-url-edit-row"),i=e.createInput("url","text","",((e,t,r)=>{let i,o=!0;return r.value?this.manager.blockedPatterns().find((e=>e.url===r.value))&&(i=_(G.patternAlreadyExists),o=!1):(i=_(G.patternInputCannotBeEmpty),o=!1),{valid:o,errorMessage:i}}));return r.createChild("div","blocked-url-edit-value").appendChild(i),e}removeAll(){this.manager.setBlockedPatterns([])}update(){const e=this.manager.blockingEnabled();this.list.element.classList.toggle("blocking-disabled",!e&&Boolean(this.manager.blockedPatterns().length)),this.enabledCheckbox.setChecked(e),this.list.clear();for(const t of this.manager.blockedPatterns())this.list.appendItem(t,e);return Promise.resolve()}blockedRequestsCount(e){if(!e)return 0;let t=0;for(const r of this.blockedCountForUrl.keys())this.matches(e,r)&&(t+=this.blockedCountForUrl.get(r));return t}matches(e,t){let r=0;const i=e.split("*");for(let e=0;e<i.length;e++){const o=i[e];if(o.length){if(r=t.indexOf(o,r),-1===r)return!1;r+=o.length}}return!0}reset(){this.blockedCountForUrl.clear(),this.updateThrottler.schedule(this.update.bind(this))}onRequestFinished(e){const t=e.data;if(t.wasBlocked()){const e=this.blockedCountForUrl.get(t.url())||0;this.blockedCountForUrl.set(t.url(),e+1),this.updateThrottler.schedule(this.update.bind(this))}}wasShown(){super.wasShown(),this.list.registerCSSFiles([D]),this.registerCSSFiles([D])}}var $=Object.freeze({__proto__:null,get blockedURLsPaneInstance(){return j},BlockedURLsPane:K});const X=new CSSStyleSheet;X.replaceSync(".event-source-messages-view .data-grid{flex:auto;border:none}\n/*# sourceURL=eventSourceMessagesView.css */\n");const J={id:"Id",type:"Type",data:"Data",time:"Time",eventSource:"Event Source",copyMessage:"Copy message"},Y=r.i18n.registerUIStrings("panels/network/EventSourceMessagesView.ts",J),Q=r.i18n.getLocalizedString.bind(void 0,Y);class Z extends o.Widget.VBox{request;dataGrid;constructor(e){super(),this.element.classList.add("event-source-messages-view"),this.request=e;const t=[{id:"id",title:Q(J.id),sortable:!0,weight:8},{id:"type",title:Q(J.type),sortable:!0,weight:8},{id:"data",title:Q(J.data),sortable:!1,weight:88},{id:"time",title:Q(J.time),sortable:!0,weight:8}];this.dataGrid=new a.SortableDataGrid.SortableDataGrid({displayName:Q(J.eventSource),columns:t,editCallback:void 0,deleteCallback:void 0,refreshCallback:void 0}),this.dataGrid.setStriped(!0),this.dataGrid.setStickToBottom(!0),this.dataGrid.setRowContextMenuCallback(this.onRowContextMenu.bind(this)),this.dataGrid.markColumnAsSortedBy("time",a.DataGrid.Order.Ascending),this.sortItems(),this.dataGrid.addEventListener(a.DataGrid.Events.SortingChanged,this.sortItems,this),this.dataGrid.setName("EventSourceMessagesView"),this.dataGrid.asWidget().show(this.element)}wasShown(){this.dataGrid.rootNode().removeChildren(),this.registerCSSFiles([X]);const e=this.request.eventSourceMessages();for(let t=0;t<e.length;++t)this.dataGrid.insertChild(new ee(e[t]));this.request.addEventListener(s.NetworkRequest.Events.EventSourceMessageAdded,this.messageAdded,this)}willHide(){this.request.removeEventListener(s.NetworkRequest.Events.EventSourceMessageAdded,this.messageAdded,this)}messageAdded(e){const t=e.data;this.dataGrid.insertChild(new ee(t))}sortItems(){const e=this.dataGrid.sortColumnId();if(!e)return;const t=re[e];t&&this.dataGrid.sortNodes(t,!this.dataGrid.isSortOrderAscending())}onRowContextMenu(e,r){e.clipboardSection().appendItem(Q(J.copyMessage),t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind(t.InspectorFrontendHost.InspectorFrontendHostInstance,r.data.data))}}class ee extends a.SortableDataGrid.SortableDataGridNode{message;constructor(e){const t=new Date(1e3*e.time),r=("0"+t.getHours()).substr(-2)+":"+("0"+t.getMinutes()).substr(-2)+":"+("0"+t.getSeconds()).substr(-2)+"."+("00"+t.getMilliseconds()).substr(-3),i=document.createElement("div");o.UIUtils.createTextChild(i,r),o.Tooltip.Tooltip.install(i,t.toLocaleString()),super({id:e.eventId,type:e.eventName,data:e.data,time:i}),this.message=e}}function te(e,t,r){const i=e(t.message),o=e(r.message);return i<o?-1:i>o?1:0}const re={id:te.bind(null,(e=>e.eventId)),type:te.bind(null,(e=>e.eventName)),time:te.bind(null,(e=>e.time))};var ie=Object.freeze({__proto__:null,EventSourceMessagesView:Z,EventSourceMessageNode:ee,EventSourceMessageNodeComparator:te,Comparators:re});const oe=new CSSStyleSheet;oe.replaceSync('.network-config{padding:12px;display:block}.network-config-group{display:flex;margin-bottom:10px;flex-wrap:wrap;flex:0 0 auto;min-height:30px}.network-config-title{margin-right:16px;width:130px}.network-config-fields{flex:2 0 200px}.panel-section-separator{height:1px;margin-bottom:10px;background:var(--color-details-hairline)}.network-config-disable-cache{line-height:28px;border-top:none;padding-top:0}.network-config-input-validation-error{color:var(--legacy-input-validation-error);margin:5px 0}.network-config-input-validation-error:empty{display:none}.network-config-throttling .chrome-select{width:100%;max-width:250px}.network-config-throttling > .network-config-title{line-height:24px}.network-config-ua > .network-config-title{line-height:20px}.network-config-ua span[is="dt-radio"].checked > *{display:none}.network-config-ua input{display:block;width:calc(100% - 20px)}.network-config-ua input[type="text"],\n.network-config-ua .chrome-select{margin-top:8px}.network-config-ua .chrome-select{width:calc(100% - 20px);max-width:250px}.network-config-ua span[is="dt-radio"]{display:block}.network-config-ua-custom{opacity:50%;padding-bottom:8px}.network-config-ua-custom.checked{opacity:100%}.client-hints-form{margin-top:14px;width:min(100%,400px)}.status-text{padding:10px;color:var(--color-accent-green)}\n/*# sourceURL=networkConfigView.css */\n');const ne={custom:"Custom...",enterACustomUserAgent:"Enter a custom user agent",customUserAgentFieldIsRequired:"Custom user agent field is required",caching:"Caching",disableCache:"Disable cache",networkThrottling:"Network throttling",userAgent:"User agent",selectAutomatically:"Use browser default",acceptedEncoding:"Accepted `Content-Encoding`s",clientHintsStatusText:"User agent updated.",networkConditionsPanelShown:"Network conditions shown"},se=r.i18n.registerUIStrings("panels/network/NetworkConfigView.ts",ne),ae=r.i18n.getLocalizedString.bind(void 0,se);let le;class de extends o.Widget.VBox{constructor(){super(!0),this.contentElement.classList.add("network-config"),this.createCacheSection(),this.contentElement.createChild("div").classList.add("panel-section-separator"),this.createNetworkThrottlingSection(),this.contentElement.createChild("div").classList.add("panel-section-separator"),this.createUserAgentSection(),this.contentElement.createChild("div").classList.add("panel-section-separator"),this.createAcceptedEncodingSection()}static instance(e={forceNew:null}){const{forceNew:t}=e;return le&&!t||(le=new de),le}static createUserAgentSelectAndInput(t){const r=e.Settings.Settings.instance().createSetting("customUserAgent",""),i=e.Settings.Settings.instance().createSetting("customUserAgentMetadata",null),n=document.createElement("select");o.ARIAUtils.setLabel(n,t);const a={title:ae(ne.custom),value:"custom"};n.appendChild(new Option(a.title,a.value));for(const e of he){const t=n.createChild("optgroup");t.label=e.title;for(const r of e.values){const e=s.NetworkManager.MultitargetNetworkManager.patchUserAgentWithChromeVersion(r.value);t.appendChild(new Option(r.title,e))}}n.selectedIndex=0;const l=o.UIUtils.createInput("","text");l.value=r.get(),o.Tooltip.Tooltip.install(l,r.get()),l.placeholder=ae(ne.enterACustomUserAgent),l.required=!0,o.ARIAUtils.setLabel(l,l.placeholder);const d=document.createElement("div");function c(){const e=r.get(),t=n.options;let i=!1;for(let r=0;r<t.length;++r)if(t[r].value===e){n.selectedIndex=r,i=!0;break}i||(n.selectedIndex=0)}return d.classList.add("network-config-input-validation-error"),o.ARIAUtils.markAsAlert(d),l.value||(d.textContent=ae(ne.customUserAgentFieldIsRequired)),c(),n.addEventListener("change",(function(){const e=n.options[n.selectedIndex].value;if(e!==a.value){r.set(e),l.value=e,o.Tooltip.Tooltip.install(l,e);const t=ce(e);i.set(t),s.NetworkManager.MultitargetNetworkManager.instance().setCustomUserAgentOverride(e,t)}else i.set(null),l.select();d.textContent="";const t=new CustomEvent("user-agent-change",{detail:{value:e}});n.dispatchEvent(t)}),!1),l.addEventListener("input",(function(){r.get()!==l.value&&(l.value?d.textContent="":d.textContent=ae(ne.customUserAgentFieldIsRequired),r.set(l.value),o.Tooltip.Tooltip.install(l,l.value),c())}),!1),{select:n,input:l,error:d}}createSection(e,t){const r=this.contentElement.createChild("section","network-config-group");return t&&r.classList.add(t),r.createChild("div","network-config-title").textContent=e,r.createChild("div","network-config-fields")}createCacheSection(){this.createSection(ae(ne.caching),"network-config-disable-cache").appendChild(o.SettingsUI.createSettingCheckbox(ae(ne.disableCache),e.Settings.Settings.instance().moduleSetting("cacheDisabled"),!0))}createNetworkThrottlingSection(){const e=ae(ne.networkThrottling),t=this.createSection(e,"network-config-throttling").createChild("select","chrome-select");l.ThrottlingManager.throttlingManager().decorateSelectWithNetworkThrottling(t),o.ARIAUtils.setLabel(t,e)}createUserAgentSection(){const t=ae(ne.userAgent),r=this.createSection(t,"network-config-ua"),i=o.UIUtils.CheckboxLabel.create(ae(ne.selectAutomatically),!0);r.appendChild(i);const n=i.checkboxElement,a=e.Settings.Settings.instance().createSetting("customUserAgentMetadata",null),l=e.Settings.Settings.instance().createSetting("customUserAgent","");l.addChangeListener((()=>{if(n.checked)return;const e=l.get(),t=ce(e);s.NetworkManager.MultitargetNetworkManager.instance().setCustomUserAgentOverride(e,t)}));const c=r.createChild("div","network-config-ua-custom");n.addEventListener("change",v);const h=de.createUserAgentSelectAndInput(t);h.select.classList.add("chrome-select"),c.appendChild(h.select),c.appendChild(h.input),c.appendChild(h.error);const u=c.createChild("div","client-hints-form"),p=new d.UserAgentClientHintsForm.UserAgentClientHintsForm,g=a.get(),m=ce(h.select.value);p.value={showMobileCheckbox:!0,showSubmitButton:!0,metaData:g||m||void 0},u.appendChild(p),h.select.addEventListener("user-agent-change",(e=>{const t=e.detail.value,r=t?ce(t):null;p.value={metaData:r||void 0,showMobileCheckbox:!0,showSubmitButton:!0},w.textContent=""})),p.addEventListener("clienthintschange",(()=>{h.select.value="custom",w.textContent=""})),p.addEventListener("clienthintssubmit",(e=>{const t=e.detail.value,r=l.get();a.set(t),s.NetworkManager.MultitargetNetworkManager.instance().setCustomUserAgentOverride(r,t),w.textContent=ae(ne.clientHintsStatusText)}));const w=r.createChild("span","status-text");function v(){const e=!n.checked;c.classList.toggle("checked",e),h.select.disabled=!e,h.input.disabled=!e,h.error.hidden=!e,p.disabled=!e;const t=e?l.get():"",r=e?ce(t):null;s.NetworkManager.MultitargetNetworkManager.instance().setCustomUserAgentOverride(t,r)}w.textContent="",v()}createAcceptedEncodingSection(){const t=ae(ne.acceptedEncoding),r=this.createSection(t,"network-config-accepted-encoding"),i=o.UIUtils.CheckboxLabel.create(ae(ne.selectAutomatically),!0);r.appendChild(i);const n=i.checkboxElement,a=e.Settings.Settings.instance().createSetting("useCustomAcceptedEncodings",!1),l=e.Settings.Settings.instance().createSetting("customAcceptedEncodings","gzip,br,deflate");function d(){a.get()?s.NetworkManager.MultitargetNetworkManager.instance().setCustomAcceptedEncodingsOverride(""===l.get()?[]:l.get().split(",")):s.NetworkManager.MultitargetNetworkManager.instance().clearCustomAcceptedEncodingsOverride()}l.addChangeListener(d),a.addChangeListener(d);const c=r.createChild("div","network-config-accepted-encoding-custom");n.checked=!a.get(),n.addEventListener("change",p);const h=new Map,u={Deflate:"deflate",Gzip:"gzip",Br:"br"};for(const e of Object.values(u)){const t=o.UIUtils.CheckboxLabel.create(e,!0);c.appendChild(t),h.set(e,t.checkboxElement)}for(const[e,t]of h)t.checked=l.get().includes(e),t.addEventListener("change",p);function p(){a.set(!n.checked);const e=[];for(const[t,r]of h)r.disabled=n.checked,r.checked&&e.push(t);l.set(e.join(","))}p()}wasShown(){super.wasShown(),this.registerCSSFiles([oe]),o.ARIAUtils.alert(ae(ne.networkConditionsPanelShown))}}function ce(e){for(const t of he)for(const r of t.values)if(e===s.NetworkManager.MultitargetNetworkManager.patchUserAgentWithChromeVersion(r.value))return r.metadata?(s.NetworkManager.MultitargetNetworkManager.patchUserAgentMetadataWithChromeVersion(r.metadata),r.metadata):null;return null}const he=[{title:"Android",values:[{title:"Android (4.0.2) Browser — Galaxy Nexus",value:"Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Google Chrome",version:"%s"}],fullVersion:"%s",platform:"Android",platformVersion:"4.0.2",architecture:"",model:"Galaxy Nexus",mobile:!0}},{title:"Android (2.3) Browser — Nexus S",value:"Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Google Chrome",version:"%s"}],fullVersion:"%s",platform:"Android",platformVersion:"2.3.6",architecture:"",model:"Nexus S",mobile:!0}}]},{title:"BlackBerry",values:[{title:"BlackBerry — BB10",value:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+",metadata:null},{title:"BlackBerry — PlayBook 2.1",value:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+",metadata:null},{title:"BlackBerry — 9900",value:"Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobile Safari/534.11+",metadata:null}]},{title:"Chrome",values:[{title:"Chrome — Android Mobile",value:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Google Chrome",version:"%s"}],fullVersion:"%s",platform:"Android",platformVersion:"6.0",architecture:"",model:"Nexus 5",mobile:!0}},{title:"Chrome — Android Mobile (high-end)",value:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Google Chrome",version:"%s"}],fullVersion:"%s",platform:"Android",platformVersion:"10",architecture:"",model:"Pixel 4",mobile:!0}},{title:"Chrome — Android Tablet",value:"Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Google Chrome",version:"%s"}],fullVersion:"%s",platform:"Android",platformVersion:"4.3",architecture:"",model:"Nexus 7",mobile:!0}},{title:"Chrome — iPhone",value:"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/%s Mobile/15E148 Safari/604.1",metadata:null},{title:"Chrome — iPad",value:"Mozilla/5.0 (iPad; CPU OS 13_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/%s Mobile/15E148 Safari/604.1",metadata:null},{title:"Chrome — Chrome OS",value:"Mozilla/5.0 (X11; CrOS x86_64 10066.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Google Chrome",version:"%s"}],fullVersion:"%s",platform:"Chrome OS",platformVersion:"10066.0.0",architecture:"x86",model:"",mobile:!1}},{title:"Chrome — Mac",value:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Google Chrome",version:"%s"}],fullVersion:"%s",platform:"macOS",platformVersion:"10_14_6",architecture:"x86",model:"",mobile:!1}},{title:"Chrome — Windows",value:"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Google Chrome",version:"%s"}],fullVersion:"%s",platform:"Windows",platformVersion:"10.0",architecture:"x86",model:"",mobile:!1}}]},{title:"Firefox",values:[{title:"Firefox — Android Mobile",value:"Mozilla/5.0 (Android 4.4; Mobile; rv:70.0) Gecko/70.0 Firefox/70.0",metadata:null},{title:"Firefox — Android Tablet",value:"Mozilla/5.0 (Android 4.4; Tablet; rv:70.0) Gecko/70.0 Firefox/70.0",metadata:null},{title:"Firefox — iPhone",value:"Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) FxiOS/1.0 Mobile/12F69 Safari/600.1.4",metadata:null},{title:"Firefox — iPad",value:"Mozilla/5.0 (iPad; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) FxiOS/1.0 Mobile/12F69 Safari/600.1.4",metadata:null},{title:"Firefox — Mac",value:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:70.0) Gecko/20100101 Firefox/70.0",metadata:null},{title:"Firefox — Windows",value:"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:70.0) Gecko/20100101 Firefox/70.0",metadata:null}]},{title:"Googlebot",values:[{title:"Googlebot",value:"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",metadata:null},{title:"Googlebot Desktop",value:"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/%s Safari/537.36",metadata:null},{title:"Googlebot Smartphone",value:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",metadata:null}]},{title:"Internet Explorer",values:[{title:"Internet Explorer 11",value:"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",metadata:null},{title:"Internet Explorer 10",value:"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)",metadata:null},{title:"Internet Explorer 9",value:"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",metadata:null},{title:"Internet Explorer 8",value:"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)",metadata:null},{title:"Internet Explorer 7",value:"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)",metadata:null}]},{title:"Microsoft Edge",values:[{title:"Microsoft Edge (Chromium) — Windows",value:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36 Edg/%s",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Microsoft Edge",version:"%s"}],fullVersion:"%s",platform:"Windows",platformVersion:"10.0",architecture:"x86",model:"",mobile:!1}},{title:"Microsoft Edge (Chromium) — Mac",value:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Chrome/%s Safari/604.1 Edg/%s",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Microsoft Edge",version:"%s"}],fullVersion:"%s",platform:"macOS",platformVersion:"10_14_6",architecture:"x86",model:"",mobile:!1}},{title:"Microsoft Edge — iPhone",value:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 EdgiOS/44.5.0.10 Mobile/15E148 Safari/604.1",metadata:null},{title:"Microsoft Edge — iPad",value:"Mozilla/5.0 (iPad; CPU OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 EdgiOS/44.5.2 Mobile/15E148 Safari/605.1.15",metadata:null},{title:"Microsoft Edge — Android Mobile",value:"Mozilla/5.0 (Linux; Android 8.1.0; Pixel Build/OPM4.171019.021.D1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.109 Mobile Safari/537.36 EdgA/42.0.0.2057",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Microsoft Edge",version:"%s"}],fullVersion:"%s",platform:"Android",platformVersion:"8.1.0",architecture:"",model:"Pixel",mobile:!0}},{title:"Microsoft Edge — Android Tablet",value:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.109 Safari/537.36 EdgA/42.0.0.2057",metadata:{brands:[{brand:"Not A;Brand",version:"99"},{brand:"Chromium",version:"%s"},{brand:"Microsoft Edge",version:"%s"}],fullVersion:"%s",platform:"Android",platformVersion:"6.0.1",architecture:"",model:"Nexus 7",mobile:!0}},{title:"Microsoft Edge (EdgeHTML) — Windows",value:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19042",metadata:null},{title:"Microsoft Edge (EdgeHTML) — XBox",value:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox One) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19041",metadata:null}]},{title:"Opera",values:[{title:"Opera — Mac",value:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36 OPR/65.0.3467.48",metadata:null},{title:"Opera — Windows",value:"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36 OPR/65.0.3467.48",metadata:null},{title:"Opera (Presto) — Mac",value:"Opera/9.80 (Macintosh; Intel Mac OS X 10.9.1) Presto/2.12.388 Version/12.16",metadata:null},{title:"Opera (Presto) — Windows",value:"Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.16",metadata:null},{title:"Opera Mobile — Android Mobile",value:"Opera/12.02 (Android 4.1; Linux; Opera Mobi/ADR-1111101157; U; en-US) Presto/2.9.201 Version/12.02",metadata:null},{title:"Opera Mini — iOS",value:"Opera/9.80 (iPhone; Opera Mini/8.0.0/34.2336; U; en) Presto/2.8.119 Version/11.10",metadata:null}]},{title:"Safari",values:[{title:"Safari — iPad iOS 13.2",value:"Mozilla/5.0 (iPad; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",metadata:null},{title:"Safari — iPhone iOS 13.2",value:"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",metadata:null},{title:"Safari — Mac",value:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15",metadata:null}]},{title:"UC Browser",values:[{title:"UC Browser — Android Mobile",value:"Mozilla/5.0 (Linux; U; Android 8.1.0; en-US; Nexus 6P Build/OPM7.181205.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.11.1.1197 Mobile Safari/537.36",metadata:null},{title:"UC Browser — iOS",value:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/16B92 UCBrowser/12.1.7.1109 Mobile AliApp(TUnionSDK/0.1.20.3)",metadata:null},{title:"UC Browser — Windows Phone",value:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920) UCBrowser/10.1.0.563 Mobile",metadata:null}]}];var ue=Object.freeze({__proto__:null,NetworkConfigView:de,userAgentGroups:he});const pe={redirect:"Redirect",sPreflight:"{PH1} + Preflight",preflight:"Preflight",selectPreflightRequest:"Select preflight request",failed:"(failed)",data:"(data)",canceled:"(canceled)",other:"other",csp:"csp",origin:"origin",devtools:"devtools",blockeds:"(blocked:{PH1})",blockedTooltip:"This request was blocked due to misconfigured response headers, click to view the headers",corsError:"CORS error",crossoriginResourceSharingErrorS:"Cross-Origin Resource Sharing error: {PH1}",finished:"Finished",pendingq:"(pending)",unknown:"(unknown)",unknownExplanation:"The request status cannot be shown here because the page that issued it unloaded while the request was in flight. You can use chrome://net-export to capture a network log and see all request details.",push:"Push / ",parser:"Parser",script:"Script",preload:"Preload",signedexchange:"signed-exchange",selectTheRequestThatTriggered:"Select the request that triggered this preflight",otherC:"Other",memoryCache:"(memory cache)",servedFromMemoryCacheResource:"Served from memory cache, resource size: {PH1}",serviceworker:"(`ServiceWorker`)",servedFromServiceworkerResource:"Served from `ServiceWorker`, resource size: {PH1}",servedFromSignedHttpExchange:"Served from Signed HTTP Exchange, resource size: {PH1}",servedFromWebBundle:"Served from Web Bundle, resource size: {PH1}",prefetchCache:"(prefetch cache)",servedFromPrefetchCacheResource:"Served from prefetch cache, resource size: {PH1}",diskCache:"(disk cache)",servedFromDiskCacheResourceSizeS:"Served from disk cache, resource size: {PH1}",pending:"Pending",level:"level 1",webBundleError:"Web Bundle error",webBundleInnerRequest:"Served from Web Bundle",webBundle:"(Web Bundle)",timeSubtitleTooltipText:"Latency (response received time - start time)",alternativeJobWonWithoutRace:"`Chrome` used a `HTTP/3` connection induced by an '`Alt-Svc`' header without racing against establishing a connection using a different `HTTP` version.",alternativeJobWonRace:"`Chrome` used a `HTTP/3` connection induced by an '`Alt-Svc`' header because it won a race against establishing a connection using a different `HTTP` version.",mainJobWonRace:"`Chrome` used this protocol because it won a race against establishing a `HTTP/3` connection.",mappingMissing:"`Chrome` did not use an alternative `HTTP` version because no alternative protocol information was available when the request was issued, but an '`Alt-Svc`' header was present in the response.",broken:"`Chrome` did not try to establish a `HTTP/3` connection because it was marked as broken.",dnsAlpnH3JobWonWithoutRace:"`Chrome` used a `HTTP/3` connection due to the `DNS record` indicating `HTTP/3` support. There was no race against establishing a connection using a different `HTTP` version.",dnsAlpnH3JobWonRace:"`Chrome` used a `HTTP/3` connection due to the `DNS record` indicating `HTTP/3` support, which won a race against establishing a connection using a different `HTTP` version.",hasOverriddenHeaders:"Request has overridden headers"},ge=r.i18n.registerUIStrings("panels/network/NetworkDataGridNode.ts",pe),me=r.i18n.getLocalizedString.bind(void 0,ge);var we;!function(e){e.RequestSelected="RequestSelected",e.RequestActivated="RequestActivated"}(we||(we={}));class ve extends a.SortableDataGrid.SortableDataGridNode{parentViewInternal;isHovered;showingInitiatorChainInternal;requestOrFirstKnownChildRequestInternal;constructor(e){super({}),this.parentViewInternal=e,this.isHovered=!1,this.showingInitiatorChainInternal=!1,this.requestOrFirstKnownChildRequestInternal=null}displayName(){return""}displayType(){return""}createCell(e){const t=this.createTD(e);return this.renderCell(t,e),t}renderCell(e,t){}isFailed(){return!1}backgroundColor(){const e=ke,t=document.hasFocus(),r=this.dataGrid&&this.dataGrid.element===document.activeElement,i=this.isFailed();return this.selected&&t&&r&&i?e.FocusSelectedHasError:this.selected&&t&&r?e.FocusSelected:this.selected?e.Selected:this.hovered()?e.Hovered:this.isOnInitiatorPath()?e.InitiatorPath:this.isOnInitiatedPath()?e.InitiatedPath:this.isStriped()?e.Stripe:e.Default}updateBackgroundColor(){const e=this.existingElement();e&&(e.style.backgroundColor=`var(${this.backgroundColor()})`,this.parentViewInternal.stylesChanged())}setStriped(e){super.setStriped(e),this.updateBackgroundColor()}select(e){super.select(e),this.updateBackgroundColor(),this.parentViewInternal.updateNodeSelectedClass(!0)}deselect(e){super.deselect(e),this.updateBackgroundColor(),this.parentViewInternal.updateNodeSelectedClass(!1)}parentView(){return this.parentViewInternal}hovered(){return this.isHovered}showingInitiatorChain(){return this.showingInitiatorChainInternal}nodeSelfHeight(){return this.parentViewInternal.rowHeight()}setHovered(e,t){this.isHovered===e&&this.showingInitiatorChainInternal===t||(this.isHovered!==e&&(this.isHovered=e,this.attached()&&this.element().classList.toggle("hover",e)),this.showingInitiatorChainInternal!==t&&(this.showingInitiatorChainInternal=t,this.showingInitiatorChainChanged()),this.parentViewInternal.stylesChanged(),this.updateBackgroundColor())}showingInitiatorChainChanged(){}isOnInitiatorPath(){return!1}isOnInitiatedPath(){return!1}request(){return null}isNavigationRequest(){return!1}clearFlatNodes(){super.clearFlatNodes(),this.requestOrFirstKnownChildRequestInternal=null}requestOrFirstKnownChildRequest(){if(this.requestOrFirstKnownChildRequestInternal)return this.requestOrFirstKnownChildRequestInternal;let e=this.request();if(e||!this.hasChildren())return this.requestOrFirstKnownChildRequestInternal=e,this.requestOrFirstKnownChildRequestInternal;let t=null;const r=this.flatChildren();for(let i=0;i<r.length;i++)e=r[i].request(),(!t||e&&e.issueTime()<t.issueTime())&&(t=e);return this.requestOrFirstKnownChildRequestInternal=t,this.requestOrFirstKnownChildRequestInternal}}const ke={Default:"--network-grid-default-color",Stripe:"--network-grid-stripe-color",Navigation:"--network-grid-navigation-color",Hovered:"--network-grid-hovered-color",InitiatorPath:"--network-grid-initiator-path-color",InitiatedPath:"--network-grid-initiated-path-color",Selected:"--network-grid-selected-color",FocusSelected:"--network-grid-focus-selected-color",FocusSelectedHasError:"--network-grid-focus-selected-color-has-error",FromFrame:"--network-grid-from-frame-color"};class be extends ve{nameCell;initiatorCell;requestInternal;isNavigationRequestInternal;selectable;isOnInitiatorPathInternal;isOnInitiatedPathInternal;linkifiedInitiatorAnchor;constructor(e,t){super(e),this.nameCell=null,this.initiatorCell=null,this.requestInternal=t,this.isNavigationRequestInternal=!1,this.selectable=!0,this.isOnInitiatorPathInternal=!1,this.isOnInitiatedPathInternal=!1}static NameComparator(e,t){const r=e.displayName().toLowerCase(),i=t.displayName().toLowerCase();if(r===i){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();return r&&i?r.identityCompare(i):r?-1:1}return r<i?-1:1}static RemoteAddressComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();if(!r||!i)return r?1:-1;const o=r.remoteAddress(),n=i.remoteAddress();return o>n?1:n>o?-1:r.identityCompare(i)}static SizeComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();return r&&i?i.cached()&&!r.cached()?1:r.cached()&&!i.cached()?-1:r.transferSize-i.transferSize||r.resourceSize-i.resourceSize||r.identityCompare(i):r?1:-1}static TypeComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();if(!r||!i)return r?1:-1;const o=e.displayType(),n=t.displayType();return o>n?1:n>o?-1:r.identityCompare(i)}static InitiatorComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();if(!r||!i)return r?1:-1;const o=e instanceof be&&e.initiatorCell,n=t instanceof be&&t.initiatorCell;if(!o||!n)return o?1:-1;const s=e,a=t,l=s.linkifiedInitiatorAnchor?s.linkifiedInitiatorAnchor.textContent||"":s.initiatorCell.title,d=a.linkifiedInitiatorAnchor?a.linkifiedInitiatorAnchor.textContent||"":a.initiatorCell.title;return l.localeCompare(d)}static InitiatorAddressSpaceComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();if(!r||!i)return r?1:-1;const o=r.clientSecurityState(),n=i.clientSecurityState();return o&&n?o.initiatorIPAddressSpace.localeCompare(n.initiatorIPAddressSpace):o?1:-1}static RemoteAddressSpaceComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();return r&&i?r.remoteAddressSpace().localeCompare(i.remoteAddressSpace()):r?1:-1}static RequestCookiesCountComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();if(!r||!i)return r?1:-1;return r.includedRequestCookies().length-i.includedRequestCookies().length||r.identityCompare(i)}static ResponseCookiesCountComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();if(!r||!i)return r?1:-1;return(r.responseCookies?r.responseCookies.length:0)-(i.responseCookies?i.responseCookies.length:0)||r.identityCompare(i)}static PriorityComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();if(!r||!i)return r?1:-1;const o=r.priority();let n=o?m.NetworkPriorities.networkPriorityWeight(o):0;n=n||0;const s=i.priority();let a=s?m.NetworkPriorities.networkPriorityWeight(s):0;return a=a||0,n-a||r.identityCompare(i)}static RequestPropertyComparator(e,t,r){const i=t.requestOrFirstKnownChildRequest(),o=r.requestOrFirstKnownChildRequest();if(!i||!o)return i?1:-1;const n=i[e],s=o[e];return n===s?i.identityCompare(o):n>s?1:-1}static RequestURLComparator(e,t){const r=e.requestOrFirstKnownChildRequest(),i=t.requestOrFirstKnownChildRequest();if(!r||!i)return r?1:-1;const o=r.url(),n=i.url();return o===n?r.identityCompare(i):o>n?1:-1}static ResponseHeaderStringComparator(e,t,r){const i=t.requestOrFirstKnownChildRequest(),o=r.requestOrFirstKnownChildRequest();if(!i||!o)return i?1:-1;const n=String(i.responseHeaderValue(e)||""),s=String(o.responseHeaderValue(e)||"");return n.localeCompare(s)||i.identityCompare(o)}static ResponseHeaderNumberComparator(e,t,r){const i=t.requestOrFirstKnownChildRequest(),o=r.requestOrFirstKnownChildRequest();if(!i||!o)return i?1:-1;const n=i.responseHeaderValue(e),s=void 0!==n?parseFloat(n):-1/0,a=o.responseHeaderValue(e),l=void 0!==a?parseFloat(a):-1/0;return s===l?i.identityCompare(o):s>l?1:-1}static ResponseHeaderDateComparator(e,t,r){const i=t.requestOrFirstKnownChildRequest(),o=r.requestOrFirstKnownChildRequest();if(!i||!o)return i?1:-1;const n=i.responseHeaderValue(e),s=o.responseHeaderValue(e),a=n?new Date(n).getTime():-1/0,l=s?new Date(s).getTime():-1/0;return a===l?i.identityCompare(o):a>l?1:-1}showingInitiatorChainChanged(){const e=this.showingInitiatorChain(),t=u.NetworkLog.NetworkLog.instance().initiatorGraphForRequest(this.requestInternal);for(const r of t.initiators){if(r===this.requestInternal)continue;const t=this.parentView().nodeForRequest(r);t&&t.setIsOnInitiatorPath(e)}for(const r of t.initiated.keys()){if(r===this.requestInternal)continue;const t=this.parentView().nodeForRequest(r);t&&t.setIsOnInitiatedPath(e)}}setIsOnInitiatorPath(e){this.isOnInitiatorPathInternal!==e&&this.attached()&&(this.isOnInitiatorPathInternal=e,this.updateBackgroundColor())}isOnInitiatorPath(){return this.isOnInitiatorPathInternal}setIsOnInitiatedPath(e){this.isOnInitiatedPathInternal!==e&&this.attached()&&(this.isOnInitiatedPathInternal=e,this.updateBackgroundColor())}isOnInitiatedPath(){return this.isOnInitiatedPathInternal}displayType(){const t=this.requestInternal.mimeType||this.requestInternal.requestContentType()||"",r=this.requestInternal.resourceType();let i=r.name();return r!==e.ResourceType.resourceTypes.Other&&r!==e.ResourceType.resourceTypes.Image||(i=t.replace(/^(application|image)\//,"")),this.requestInternal.isRedirect()&&(i+=" / "+me(pe.redirect)),i}displayName(){return this.requestInternal.name()}request(){return this.requestInternal}isNavigationRequest(){const e=s.PageLoad.PageLoad.forRequest(this.requestInternal);return!!e&&e.mainRequest===this.requestInternal}nodeSelfHeight(){return this.parentView().rowHeight()}createCells(e){this.nameCell=null,this.initiatorCell=null,e.classList.toggle("network-error-row",this.isFailed()),e.classList.toggle("network-navigation-row",this.isNavigationRequestInternal),super.createCells(e),this.updateBackgroundColor()}setTextAndTitle(e,t,r){o.UIUtils.createTextChild(e,t),o.Tooltip.Tooltip.install(e,r||t)}setTextAndTitleAsLink(e,t,r,i){const n=document.createElement("span");n.classList.add("devtools-link"),n.textContent=t,n.addEventListener("click",i),e.appendChild(n),o.Tooltip.Tooltip.install(e,r)}renderCell(e,t){const r=e;switch(t){case"name":this.renderPrimaryCell(r,t);break;case"path":this.renderPrimaryCell(r,t,this.requestInternal.pathname);break;case"url":this.renderPrimaryCell(r,t,this.requestInternal.url());break;case"method":{const e=this.requestInternal.preflightRequest();e?(this.setTextAndTitle(r,`${this.requestInternal.requestMethod} + `,me(pe.sPreflight,{PH1:this.requestInternal.requestMethod})),r.appendChild(w.Linkifier.Linkifier.linkifyRevealable(e,me(pe.preflight),void 0,me(pe.selectPreflightRequest)))):this.setTextAndTitle(r,this.requestInternal.requestMethod);break}case"status":this.renderStatusCell(r);break;case"protocol":this.renderProtocolCell(r);break;case"scheme":this.setTextAndTitle(r,this.requestInternal.scheme);break;case"domain":this.setTextAndTitle(r,this.requestInternal.domain);break;case"remoteaddress":this.setTextAndTitle(r,this.requestInternal.remoteAddress());break;case"remoteaddress-space":this.renderAddressSpaceCell(r,this.requestInternal.remoteAddressSpace());break;case"cookies":this.setTextAndTitle(r,this.arrayLength(this.requestInternal.includedRequestCookies()));break;case"setcookies":this.setTextAndTitle(r,this.arrayLength(this.requestInternal.responseCookies));break;case"priority":{const e=this.requestInternal.priority();this.setTextAndTitle(r,e?m.NetworkPriorities.uiLabelForNetworkPriority(e):"");break}case"connectionid":this.setTextAndTitle(r,"0"===this.requestInternal.connectionId?"":this.requestInternal.connectionId);break;case"type":this.setTextAndTitle(r,this.displayType());break;case"initiator":this.renderInitiatorCell(r);break;case"initiator-address-space":{const e=this.requestInternal.clientSecurityState();this.renderAddressSpaceCell(r,e?e.initiatorIPAddressSpace:"Unknown");break}case"size":this.renderSizeCell(r);break;case"time":this.renderTimeCell(r);break;case"timeline":this.setTextAndTitle(r,"");break;default:this.setTextAndTitle(r,this.requestInternal.responseHeaderValue(t)||"")}}arrayLength(e){return e?String(e.length):""}select(e){super.select(e),this.parentView().dispatchEventToListeners(we.RequestSelected,this.requestInternal)}highlightMatchedSubstring(e){if(!e||!this.nameCell||null===this.nameCell.textContent)return[];this.element();const t=[],r=this.nameCell.textContent.match(e);return r&&o.UIUtils.highlightSearchResult(this.nameCell,r.index||0,r[0].length,t),t}openInNewTab(){t.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(this.requestInternal.url())}isFailed(){if(this.requestInternal.failed&&!this.requestInternal.statusCode)return!0;if(this.requestInternal.statusCode>=400)return!0;const e=this.requestInternal.signedExchangeInfo();return!(null===e||!Boolean(e.errors))||(!(!this.requestInternal.webBundleInfo()?.errorMessage&&!this.requestInternal.webBundleInnerRequestInfo()?.errorMessage)||!!this.requestInternal.corsErrorStatus())}renderPrimaryCell(t,r,i){if(0===this.dataGrid.indexOfVisibleColumn(r)){const r=this.leftPadding?this.leftPadding+"px":"";let i;if(t.style.setProperty("padding-left",r),this.nameCell=t,t.addEventListener("dblclick",this.openInNewTab.bind(this),!1),t.addEventListener("mousedown",(()=>{this.select(),this.parentView().dispatchEventToListeners(we.RequestActivated,{showPanel:!0})})),this.requestInternal.resourceType()===e.ResourceType.resourceTypes.Image){const e=document.createElement("img");e.classList.add("image-network-icon-preview"),e.alt=this.requestInternal.resourceType().title(),this.requestInternal.populateImageSource(e),i=document.createElement("div"),i.classList.add("image"),i.appendChild(e)}else{const e=v(this.requestInternal.resourceType());i=document.createElement("div"),i.title=this.requestInternal.resourceType().title(),i.style.setProperty("-webkit-mask",`url('${new URL(`../../Images/${e.iconName}.svg`,import.meta.url).toString()}')  no-repeat center /99%`),i.style.setProperty("background-color",e.color)}i.classList.add("icon"),t.appendChild(i)}if("name"===r){const e=this.requestInternal.webBundleInnerRequestInfo();if(e){const r=document.createElement("div");r.classList.add("icon"),r.title=me(pe.webBundleInnerRequest),r.style.setProperty("-webkit-mask",`url('${new URL("../../Images/bundle.svg",import.meta.url).toString()}')  no-repeat center /99%`),r.style.setProperty("background-color","var(--icon-info)");const i=s.NetworkManager.NetworkManager.forRequest(this.requestInternal);e.bundleRequestId&&i?t.appendChild(w.Linkifier.Linkifier.linkifyRevealable(new g.NetworkRequestId.NetworkRequestId(e.bundleRequestId,i),r)):t.appendChild(r)}const r=n.StringUtilities.trimMiddle(this.requestInternal.name(),100),i=s.NetworkManager.NetworkManager.forRequest(this.requestInternal);o.UIUtils.createTextChild(t,i?i.target().decorateLabel(r):r),this.appendSubtitle(t,this.requestInternal.path()),this.requestInternal.url().startsWith("data")||o.Tooltip.Tooltip.install(t,this.requestInternal.url())}else i&&o.UIUtils.createTextChild(t,i)}renderStatusCell(e){e.classList.toggle("network-dim-cell",!this.isFailed()&&(this.requestInternal.cached()||!this.requestInternal.statusCode));const t=this.requestInternal.corsErrorStatus(),i=this.requestInternal.webBundleInfo()?.errorMessage||this.requestInternal.webBundleInnerRequestInfo()?.errorMessage;if(i)this.setTextAndTitle(e,me(pe.webBundleError),i);else if(!this.requestInternal.failed||this.requestInternal.canceled||this.requestInternal.wasBlocked()||t)if(this.requestInternal.statusCode&&this.requestInternal.statusCode>=400)o.UIUtils.createTextChild(e,String(this.requestInternal.statusCode)),this.appendSubtitle(e,this.requestInternal.statusText),o.Tooltip.Tooltip.install(e,this.requestInternal.statusCode+" "+this.requestInternal.statusText);else if(!this.requestInternal.statusCode&&this.requestInternal.parsedURL.isDataURL())this.setTextAndTitle(e,me(pe.data));else if(!this.requestInternal.statusCode&&this.requestInternal.canceled)this.setTextAndTitle(e,me(pe.canceled));else if(this.requestInternal.wasBlocked()){let t=me(pe.other),i=!1;switch(this.requestInternal.blockedReason()){case"other":t=me(pe.other);break;case"csp":t=me(pe.csp);break;case"mixed-content":t=r.i18n.lockedString("mixed-content");break;case"origin":t=me(pe.origin);break;case"inspector":t=me(pe.devtools);break;case"subresource-filter":t=r.i18n.lockedString("subresource-filter");break;case"content-type":t=r.i18n.lockedString("content-type");break;case"coep-frame-resource-needs-coep-header":i=!0,t=r.i18n.lockedString("CoepFrameResourceNeedsCoepHeader");break;case"coop-sandboxed-iframe-cannot-navigate-to-coop-page":i=!0,t=r.i18n.lockedString("CoopSandboxedIframeCannotNavigateToCoopPage");break;case"corp-not-same-origin":i=!0,t=r.i18n.lockedString("NotSameOrigin");break;case"corp-not-same-site":i=!0,t=r.i18n.lockedString("NotSameSite");break;case"corp-not-same-origin-after-defaulted-to-same-origin-by-coep":i=!0,t=r.i18n.lockedString("NotSameOriginAfterDefaultedToSameOriginByCoep")}i?this.setTextAndTitleAsLink(e,me(pe.blockeds,{PH1:t}),me(pe.blockedTooltip),(()=>{const e=c.Runtime.experiments.isEnabled(c.Runtime.ExperimentName.HEADER_OVERRIDES)?g.UIRequestLocation.UIRequestTabs.HeadersComponent:g.UIRequestLocation.UIRequestTabs.Headers;this.parentView().dispatchEventToListeners(we.RequestActivated,{showPanel:!0,tab:e})})):this.setTextAndTitle(e,me(pe.blockeds,{PH1:t}))}else if(t)this.setTextAndTitle(e,me(pe.corsError),me(pe.crossoriginResourceSharingErrorS,{PH1:t.corsError}));else if(this.requestInternal.statusCode){if(this.requestInternal.hasOverriddenHeaders()){const t=document.createElement("div");t.classList.add("network-override-marker"),t.title=me(pe.hasOverriddenHeaders),e.appendChild(t)}o.UIUtils.createTextChild(e,String(this.requestInternal.statusCode)),this.appendSubtitle(e,this.requestInternal.statusText),o.Tooltip.Tooltip.install(e,this.requestInternal.statusCode+" "+this.requestInternal.statusText)}else this.requestInternal.finished?this.setTextAndTitle(e,me(pe.finished)):this.requestInternal.preserved?this.setTextAndTitle(e,me(pe.unknown),me(pe.unknownExplanation)):this.setTextAndTitle(e,me(pe.pendingq));else{const t=me(pe.failed);this.requestInternal.localizedFailDescription?(o.UIUtils.createTextChild(e,t),this.appendSubtitle(e,this.requestInternal.localizedFailDescription,!0),o.Tooltip.Tooltip.install(e,t+" "+this.requestInternal.localizedFailDescription)):this.setTextAndTitle(e,t)}}renderProtocolCell(e){switch(o.UIUtils.createTextChild(e,this.requestInternal.protocol),this.requestInternal.alternateProtocolUsage){case"alternativeJobWonWithoutRace":o.Tooltip.Tooltip.install(e,pe.alternativeJobWonWithoutRace);break;case"alternativeJobWonRace":o.Tooltip.Tooltip.install(e,pe.alternativeJobWonRace);break;case"mainJobWonRace":o.Tooltip.Tooltip.install(e,pe.mainJobWonRace);break;case"mappingMissing":o.Tooltip.Tooltip.install(e,pe.mappingMissing);break;case"broken":o.Tooltip.Tooltip.install(e,pe.broken);break;case"dnsAlpnH3JobWonWithoutRace":o.Tooltip.Tooltip.install(e,pe.dnsAlpnH3JobWonWithoutRace);break;case"dnsAlpnH3JobWonRace":o.Tooltip.Tooltip.install(e,pe.dnsAlpnH3JobWonRace);break;default:o.Tooltip.Tooltip.install(e,this.requestInternal.protocol)}}#e(){if(this.requestInternal.resourceType().isStyleSheet())return t.UserMetrics.Action.StyleSheetInitiatorLinkClicked}renderInitiatorCell(e){this.initiatorCell=e;const t=this.requestInternal,r=u.NetworkLog.NetworkLog.instance().initiatorInfoForRequest(t),i=t.timing;switch(i&&i.pushStart&&e.appendChild(document.createTextNode(me(pe.push))),r.type){case s.NetworkRequest.InitiatorType.Parser:{const t=p.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(r.url);e.appendChild(w.Linkifier.Linkifier.linkifyURL(r.url,{text:t?t.displayName():void 0,lineNumber:r.lineNumber,columnNumber:r.columnNumber,userMetric:this.#e()})),this.appendSubtitle(e,me(pe.parser));break}case s.NetworkRequest.InitiatorType.Redirect:{o.Tooltip.Tooltip.install(e,r.url);const i=t.redirectSource();console.assert(null!==i),this.parentView().nodeForRequest(i)?e.appendChild(w.Linkifier.Linkifier.linkifyRevealable(i,h.ResourceUtils.displayNameForURL(i.url()))):e.appendChild(w.Linkifier.Linkifier.linkifyURL(i.url())),this.appendSubtitle(e,me(pe.redirect));break}case s.NetworkRequest.InitiatorType.Script:{const i=s.NetworkManager.NetworkManager.forRequest(t)?.target()||null,n=this.parentView().linkifier();r.stack?this.linkifiedInitiatorAnchor=n.linkifyStackTraceTopFrame(i,r.stack):this.linkifiedInitiatorAnchor=n.linkifyScriptLocation(i,r.scriptId,r.url,r.lineNumber,{columnNumber:r.columnNumber,inlineFrameIndex:0}),o.Tooltip.Tooltip.install(this.linkifiedInitiatorAnchor,""),e.appendChild(this.linkifiedInitiatorAnchor),this.appendSubtitle(e,me(pe.script)),e.classList.add("network-script-initiated");break}case s.NetworkRequest.InitiatorType.Preload:o.Tooltip.Tooltip.install(e,me(pe.preload)),e.classList.add("network-dim-cell"),e.appendChild(document.createTextNode(me(pe.preload)));break;case s.NetworkRequest.InitiatorType.SignedExchange:e.appendChild(w.Linkifier.Linkifier.linkifyURL(r.url)),this.appendSubtitle(e,me(pe.signedexchange));break;case s.NetworkRequest.InitiatorType.Preflight:if(e.appendChild(document.createTextNode(me(pe.preflight))),r.initiatorRequest){const t=o.Icon.Icon.create("arrow-up-down-circle"),i=w.Linkifier.Linkifier.linkifyRevealable(r.initiatorRequest,t,void 0,me(pe.selectTheRequestThatTriggered),"trailing-link-icon");o.ARIAUtils.setLabel(i,me(pe.selectTheRequestThatTriggered)),e.appendChild(i)}break;default:o.Tooltip.Tooltip.install(e,me(pe.otherC)),e.classList.add("network-dim-cell"),e.appendChild(document.createTextNode(me(pe.otherC)))}}renderAddressSpaceCell(e,t){"Unknown"!==t&&o.UIUtils.createTextChild(e,t)}renderSizeCell(e){const t=n.NumberUtilities.bytesToString(this.requestInternal.resourceSize);if(this.requestInternal.cachedInMemory())o.UIUtils.createTextChild(e,me(pe.memoryCache)),o.Tooltip.Tooltip.install(e,me(pe.servedFromMemoryCacheResource,{PH1:t})),e.classList.add("network-dim-cell");else if(this.requestInternal.fetchedViaServiceWorker)o.UIUtils.createTextChild(e,me(pe.serviceworker)),o.Tooltip.Tooltip.install(e,me(pe.servedFromServiceworkerResource,{PH1:t})),e.classList.add("network-dim-cell");else if(this.requestInternal.redirectSourceSignedExchangeInfoHasNoErrors())o.UIUtils.createTextChild(e,r.i18n.lockedString("(signed-exchange)")),o.Tooltip.Tooltip.install(e,me(pe.servedFromSignedHttpExchange,{PH1:t})),e.classList.add("network-dim-cell");else if(this.requestInternal.webBundleInnerRequestInfo())o.UIUtils.createTextChild(e,me(pe.webBundle)),o.Tooltip.Tooltip.install(e,me(pe.servedFromWebBundle,{PH1:t})),e.classList.add("network-dim-cell");else if(this.requestInternal.fromPrefetchCache())o.UIUtils.createTextChild(e,me(pe.prefetchCache)),o.Tooltip.Tooltip.install(e,me(pe.servedFromPrefetchCacheResource,{PH1:t})),e.classList.add("network-dim-cell");else if(this.requestInternal.cached())o.UIUtils.createTextChild(e,me(pe.diskCache)),o.Tooltip.Tooltip.install(e,me(pe.servedFromDiskCacheResourceSizeS,{PH1:t})),e.classList.add("network-dim-cell");else{const r=n.NumberUtilities.bytesToString(this.requestInternal.transferSize);o.UIUtils.createTextChild(e,r),o.Tooltip.Tooltip.install(e,`${r} transferred over network, resource size: ${t}`)}this.appendSubtitle(e,t)}renderTimeCell(e){this.requestInternal.duration>0?(this.setTextAndTitle(e,r.TimeUtilities.secondsToString(this.requestInternal.duration)),this.appendSubtitle(e,r.TimeUtilities.secondsToString(this.requestInternal.latency),!1,me(pe.timeSubtitleTooltipText))):this.requestInternal.preserved?this.setTextAndTitle(e,me(pe.unknown),me(pe.unknownExplanation)):(e.classList.add("network-dim-cell"),this.setTextAndTitle(e,me(pe.pending)))}appendSubtitle(e,t,r=!1,i=""){const n=document.createElement("div");n.classList.add("network-cell-subtitle"),r&&n.classList.add("network-cell-subtitle-show-inline-when-selected"),n.textContent=t,i&&o.Tooltip.Tooltip.install(n,i),e.appendChild(n)}}class fe extends ve{createCells(e){super.createCells(e);const t=this.dataGrid.visibleColumnsArray[0],r=`${t.title}`,i=me(pe.level);this.nodeAccessibleText=`${i} ${r}: ${this.cellAccessibleTextMap.get(t.id)}`}renderCell(e,t){if(0===this.dataGrid.indexOfVisibleColumn(t)){const r=e,i=this.leftPadding?this.leftPadding+"px":"";r.style.setProperty("padding-left",i),r.classList.add("disclosure"),this.setCellAccessibleName(r.textContent||"",r,t)}}select(e){super.select(e);const t=this.traverseNextNode(!1,void 0,!0)?.request();t&&this.parentView().dispatchEventToListeners(we.RequestSelected,t)}}var Ce=Object.freeze({__proto__:null,get Events(){return we},NetworkNode:ve,_backgroundColors:ke,NetworkRequestNode:be,NetworkGroupNode:fe});const Se=new CSSStyleSheet;Se.replaceSync(".request-cookies-view{overflow:auto;padding:12px;height:100%;background-color:var(--color-background)}.request-cookies-view .request-cookies-title{font-size:12px;font-weight:bold;margin-right:30px;color:var(--color-text-primary)}.request-cookies-view .cookie-line{margin-top:6px;display:flex}.request-cookies-view .cookies-panel-item{margin-top:6px;margin-bottom:16px;flex:none}@media (forced-colors: active){td.flagged-cookie-attribute-cell .cookie-warning-icon{forced-color-adjust:none;filter:grayscale()}}\n/*# sourceURL=requestCookiesView.css */\n");const Te={thisRequestHasNoCookies:"This request has no cookies.",requestCookies:"Request Cookies",cookiesThatWereSentToTheServerIn:"Cookies that were sent to the server in the 'cookie' header of the request",showFilteredOutRequestCookies:"show filtered out request cookies",noRequestCookiesWereSent:"No request cookies were sent.",responseCookies:"Response Cookies",cookiesThatWereReceivedFromThe:"Cookies that were received from the server in the '`set-cookie`' header of the response",malformedResponseCookies:"Malformed Response Cookies",cookiesThatWereReceivedFromTheServer:"Cookies that were received from the server in the '`set-cookie`' header of the response but were malformed",siteHasCookieInOtherPartition:"This site has cookies in another partition, that were not sent with this request. {PH1}",learnMore:"Learn more"},ye=r.i18n.registerUIStrings("panels/network/RequestCookiesView.ts",Te),xe=r.i18n.getLocalizedString.bind(void 0,ye);class Re extends o.Widget.Widget{request;showFilteredOutCookiesSetting;emptyWidget;requestCookiesTitle;requestCookiesEmpty;requestCookiesTable;responseCookiesTitle;responseCookiesTable;siteHasCookieInOtherPartition;malformedResponseCookiesTitle;malformedResponseCookiesList;constructor(t){super(),this.element.classList.add("request-cookies-view"),this.request=t,this.showFilteredOutCookiesSetting=e.Settings.Settings.instance().createSetting("show-filtered-out-request-cookies",!1),this.emptyWidget=new o.EmptyWidget.EmptyWidget(xe(Te.thisRequestHasNoCookies)),this.emptyWidget.show(this.element),this.requestCookiesTitle=this.element.createChild("div");const i=this.requestCookiesTitle.createChild("span","request-cookies-title");i.textContent=xe(Te.requestCookies),o.Tooltip.Tooltip.install(i,xe(Te.cookiesThatWereSentToTheServerIn));const n=o.SettingsUI.createSettingCheckbox(xe(Te.showFilteredOutRequestCookies),this.showFilteredOutCookiesSetting,!0);n.checkboxElement.addEventListener("change",(()=>{this.refreshRequestCookiesView()})),this.requestCookiesTitle.appendChild(n),this.requestCookiesEmpty=this.element.createChild("div","cookies-panel-item"),this.requestCookiesEmpty.textContent=xe(Te.noRequestCookiesWereSent),this.requestCookiesTable=new C.CookiesTable.CookiesTable(!0),this.requestCookiesTable.contentElement.classList.add("cookie-table","cookies-panel-item"),this.requestCookiesTable.show(this.element),this.siteHasCookieInOtherPartition=this.element.createChild("div","cookies-panel-item site-has-cookies-in-other-partition"),this.siteHasCookieInOtherPartition.appendChild(r.i18n.getFormatLocalizedString(ye,Te.siteHasCookieInOtherPartition,{PH1:o.XLink.XLink.create("https://developer.chrome.com/en/docs/privacy-sandbox/chips/",xe(Te.learnMore))})),this.responseCookiesTitle=this.element.createChild("div","request-cookies-title"),this.responseCookiesTitle.textContent=xe(Te.responseCookies),this.responseCookiesTitle.title=xe(Te.cookiesThatWereReceivedFromThe),this.responseCookiesTable=new C.CookiesTable.CookiesTable(!0),this.responseCookiesTable.contentElement.classList.add("cookie-table","cookies-panel-item"),this.responseCookiesTable.show(this.element),this.malformedResponseCookiesTitle=this.element.createChild("div","request-cookies-title"),this.malformedResponseCookiesTitle.textContent=xe(Te.malformedResponseCookies),o.Tooltip.Tooltip.install(this.malformedResponseCookiesTitle,xe(Te.cookiesThatWereReceivedFromTheServer)),this.malformedResponseCookiesList=this.element.createChild("div")}getRequestCookies(){const e=new Map,t=this.request.includedRequestCookies().slice();if(this.showFilteredOutCookiesSetting.get())for(const r of this.request.blockedRequestCookies())e.set(r.cookie,r.blockedReasons.map((e=>({attribute:s.NetworkRequest.cookieBlockedReasonToAttribute(e),uiString:s.NetworkRequest.cookieBlockedReasonToUiString(e)})))),t.push(r.cookie);return{requestCookies:t,requestCookieToBlockedReasons:e}}getResponseCookies(){let e=[];const t=new Map,r=[];if(this.request.responseCookies.length){const i=this.request.blockedResponseCookies().map((e=>e.cookieLine));e=this.request.responseCookies.filter((e=>{const t=i.indexOf(e.getCookieLine());return-1===t||(i[t]=null,!1)}));for(const i of this.request.blockedResponseCookies()){const o=s.CookieParser.CookieParser.parseSetCookie(i.cookieLine);if(o&&!o.length||i.blockedReasons.includes("SyntaxError")||i.blockedReasons.includes("NameValuePairExceedsMaxSize")){r.push(i);continue}let n=i.cookie;!n&&o&&(n=o[0]),n&&(t.set(n,i.blockedReasons.map((e=>({attribute:s.NetworkRequest.setCookieBlockedReasonToAttribute(e),uiString:s.NetworkRequest.setCookieBlockedReasonToUiString(e)})))),e.push(n))}}return{responseCookies:e,responseCookieToBlockedReasons:t,malformedResponseCookies:r}}refreshRequestCookiesView(){if(!this.isShowing())return;this.request.hasRequestCookies()||this.request.responseCookies.length?this.emptyWidget.hideWidget():this.emptyWidget.showWidget();const{requestCookies:e,requestCookieToBlockedReasons:t}=this.getRequestCookies(),{responseCookies:r,responseCookieToBlockedReasons:i,malformedResponseCookies:n}=this.getResponseCookies();if(e.length?(this.requestCookiesTitle.classList.remove("hidden"),this.requestCookiesEmpty.classList.add("hidden"),this.requestCookiesTable.showWidget(),this.requestCookiesTable.setCookies(e,t)):this.request.blockedRequestCookies().length?(this.requestCookiesTitle.classList.remove("hidden"),this.requestCookiesEmpty.classList.remove("hidden"),this.requestCookiesTable.hideWidget()):(this.requestCookiesTitle.classList.add("hidden"),this.requestCookiesEmpty.classList.add("hidden"),this.requestCookiesTable.hideWidget()),r.length?(this.responseCookiesTitle.classList.remove("hidden"),this.responseCookiesTable.showWidget(),this.responseCookiesTable.setCookies(r,i)):(this.responseCookiesTitle.classList.add("hidden"),this.responseCookiesTable.hideWidget()),n.length){this.malformedResponseCookiesTitle.classList.remove("hidden"),this.malformedResponseCookiesList.classList.remove("hidden"),this.malformedResponseCookiesList.removeChildren();for(const e of n){const t=this.malformedResponseCookiesList.createChild("span","cookie-line source-code"),r=new k.Icon.Icon;r.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},r.classList.add("cookie-warning-icon"),t.appendChild(r),o.UIUtils.createTextChild(t,e.cookieLine),e.blockedReasons.includes("NameValuePairExceedsMaxSize")?t.title=s.NetworkRequest.setCookieBlockedReasonToUiString("NameValuePairExceedsMaxSize"):t.title=s.NetworkRequest.setCookieBlockedReasonToUiString("SyntaxError")}}else this.malformedResponseCookiesTitle.classList.add("hidden"),this.malformedResponseCookiesList.classList.add("hidden");this.request.siteHasCookieInOtherPartition()?this.siteHasCookieInOtherPartition.classList.remove("hidden"):this.siteHasCookieInOtherPartition.classList.add("hidden")}wasShown(){super.wasShown(),this.registerCSSFiles([Se]),this.request.addEventListener(s.NetworkRequest.Events.RequestHeadersChanged,this.refreshRequestCookiesView,this),this.request.addEventListener(s.NetworkRequest.Events.ResponseHeadersChanged,this.refreshRequestCookiesView,this),this.refreshRequestCookiesView()}willHide(){this.request.removeEventListener(s.NetworkRequest.Events.RequestHeadersChanged,this.refreshRequestCookiesView,this),this.request.removeEventListener(s.NetworkRequest.Events.ResponseHeadersChanged,this.refreshRequestCookiesView,this)}}var Ie=Object.freeze({__proto__:null,RequestCookiesView:Re});const qe=new CSSStyleSheet;qe.replaceSync('.object-properties-section-dimmed{opacity:60%}.object-properties-section{padding:0;color:var(--color-text-primary);display:flex;flex-direction:column}.object-properties-section li{user-select:text}.object-properties-section li::before{top:-1px;margin-right:2px}.object-properties-section li.editing-sub-part{padding:3px 12px 8px 6px;margin:-1px -6px -8px;text-overflow:clip}.object-properties-section li.editing{margin-left:10px;text-overflow:clip}.tree-outline ol.title-less-mode{padding-left:0}.object-properties-section .own-property{font-weight:bold}.object-properties-section .synthetic-property{color:var(--color-text-secondary)}.object-properties-section .private-property-hash{color:var(--color-text-primary)}.object-properties-section-root-element{display:flex;flex-direction:row}.object-properties-section .editable-div{overflow:hidden}.object-properties-section [data-webidl="true"] > .name-and-value > .adorner{flex-shrink:0;width:16px;height:16px;margin-right:2px}.object-properties-section [data-webidl="true"] > .name-and-value > .name{font-weight:bold}.name-and-value{overflow:hidden;line-height:16px;display:flex;white-space:nowrap}.name-and-value .separator{white-space:pre;flex-shrink:0}.editing-sub-part .name-and-value{overflow:visible;display:inline-flex}.property-prompt{margin-left:4px}.tree-outline.hide-selection-when-blurred .selected:focus-visible{background:none}.tree-outline.hide-selection-when-blurred .selected:focus-visible ::slotted(*),\n.tree-outline.hide-selection-when-blurred .selected:focus-visible .tree-element-title,\n.tree-outline.hide-selection-when-blurred .selected:focus-visible .name-and-value,\n.tree-outline.hide-selection-when-blurred .selected:focus-visible .gray-info-message{background:var(--legacy-focus-bg-color);border-radius:2px;box-shadow:0 0 0 2px var(--legacy-focus-bg-color)}@media (forced-colors: active){.object-properties-section-dimmed{opacity:100%}.tree-outline.hide-selection-when-blurred .selected:focus-visible{background:Highlight}.tree-outline li:hover .tree-element-title,\n  .tree-outline li.selected .tree-element-title{color:ButtonText}.tree-outline.hide-selection-when-blurred .selected:focus-visible .tree-element-title,\n  .tree-outline.hide-selection-when-blurred .selected:focus-visible .name-and-value{background:transparent;box-shadow:none}.tree-outline.hide-selection-when-blurred .selected:focus-visible span,\n  .tree-outline.hide-selection-when-blurred .selected:focus-visible .gray-info-message{color:HighlightText}.tree-outline-disclosure:hover li.parent::before{background-color:ButtonText}}\n/*# sourceURL=objectPropertiesSection.css */\n');const Le=new CSSStyleSheet;Le.replaceSync(".value.object-value-node:hover{background-color:var(--item-hover-color)}.object-value-function-prefix,\n.object-value-boolean{color:var(--color-syntax-3)}.object-value-function{font-style:italic}.object-value-function.linkified:hover{--override-linkified-hover-background:rgb(0 0 0/10%);background-color:var(--override-linkified-hover-background);cursor:pointer}.-theme-with-dark-background .object-value-function.linkified:hover,\n:host-context(.-theme-with-dark-background) .object-value-function.linkified:hover{--override-linkified-hover-background:rgb(230 230 230/10%)}.object-value-number{color:var(--color-syntax-3)}.object-value-bigint{color:var(--color-syntax-6)}.object-value-string,\n.object-value-regexp,\n.object-value-symbol{white-space:pre;unicode-bidi:-webkit-isolate;color:var(--color-syntax-1)}.object-value-node{position:relative;vertical-align:baseline;color:var(--color-syntax-7);white-space:nowrap}.object-value-null,\n.object-value-undefined{color:var(--color-text-disabled)}.object-value-unavailable{color:var(--color-syntax-2)}.object-value-calculate-value-button:hover{text-decoration:underline}.object-properties-section-custom-section{display:inline-flex;flex-direction:column}.-theme-with-dark-background .object-value-number,\n:host-context(.-theme-with-dark-background) .object-value-number,\n.-theme-with-dark-background .object-value-boolean,\n:host-context(.-theme-with-dark-background) .object-value-boolean{--override-primitive-dark-mode-color:hsl(252deg 100% 75%);color:var(--override-primitive-dark-mode-color)}.object-properties-section .object-description{color:var(--color-text-secondary)}.value .object-properties-preview{white-space:nowrap}.name{color:var(--color-syntax-2);flex-shrink:0}.object-properties-preview .name{color:var(--color-text-secondary)}@media (forced-colors: active){.object-value-calculate-value-button:hover{forced-color-adjust:none;color:Highlight}}\n/*# sourceURL=objectValue.css */\n");const Fe=new CSSStyleSheet;Fe.replaceSync('.tree-outline{padding-left:0;--override-error-background-color:#d93025;--override-error-text-color:#fff;--override-call-to-action-border-color:#f29900;--override-header-highlight-background-color:#ffff78}.-theme-with-dark-background .tree-outline,\n:host-context(.-theme-with-dark-background) .tree-outline{--override-error-text-color:#000;--override-call-to-action-border-color:rgb(255 166 13);--override-header-highlight-background-color:rgb(135 135 0)}.tree-outline > ol{padding-bottom:5px;border-bottom:solid 1px var(--color-details-hairline)}.tree-outline > .parent{user-select:none;font-weight:bold;color:var(--color-text-primary);margin-top:-1px;display:flex;align-items:center;height:26px}.tree-outline li{display:block;padding-left:5px;line-height:20px}.tree-outline li:not(.parent){margin-left:10px}.tree-outline li:not(.parent)::before{display:none}.tree-outline .caution{margin-left:4px;display:inline-block;font-weight:bold}.tree-outline li.expanded .header-count{display:none}.tree-outline li .headers-title-left{min-width:50%;display:flex;justify-content:space-between}.tree-outline li .header-toggle{display:none}.tree-outline li .status-from-cache{color:var(--color-text-secondary)}.tree-outline li.expanded .header-toggle{display:inline;margin-left:30px;font-weight:normal;color:var(--color-text-primary)}.tree-outline li .header-toggle:hover{color:var(--color-text-secondary);cursor:pointer}.tree-outline .header-name{color:var(--color-text-secondary);display:inline-block;margin-right:0.25em;font-weight:bold;vertical-align:top;white-space:pre-wrap}.tree-outline .header-separator{user-select:none}.tree-outline .header-badge-text{font-variant:small-caps;font-weight:500;white-space:pre-wrap;word-break:break-all}.tree-outline .header-warning{color:var(--override-error-background-color)}.tree-outline .header-badge{display:inline;margin-right:0.75em;background-color:var(--override-error-background-color);color:var(--override-error-text-color);border-radius:100vh;padding-left:6px;padding-right:6px}.tree-outline .header-value{display:inline;margin-right:1em;white-space:pre-wrap;word-break:break-all;margin-top:1px}.tree-outline .call-to-action{background-color:var(--color-background-elevation-1);padding:8px;border-radius:2px}.tree-outline .selected .call-to-action{background-color:transparent;padding:8px;border-radius:2px}.tree-outline .call-to-action-body{padding:6px 0;margin-left:9.5px;border-left:2px solid var(--override-call-to-action-border-color);padding-left:18px}.tree-outline .call-to-action .explanation{font-weight:bold}.tree-outline .call-to-action code{font-size:90%}.tree-outline .call-to-action .example .comment::before{content:" — "}.tree-outline .empty-request-header{color:var(--color-text-disabled)}.request-headers-show-more-button{border:none;border-radius:3px;display:inline-block;font-size:12px;font-family:sans-serif;cursor:pointer;margin:0 4px;padding:2px 4px}.request-headers-caution{display:flex;gap:6px}.header-highlight{background-color:var(--override-header-highlight-background-color)}.header-highlight:focus{background-color:var(--legacy-selection-bg-color)}.x-client-data-details{padding-left:10px}@media (forced-colors: active){:host-context(.request-headers-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected:focus{background:Highlight}:host-context(.request-headers-tree) ol.tree-outline:not(.hide-selection-when-blurred) li::before{background-color:ButtonText}:host-context(.request-headers-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected.parent::before{background-color:HighlightText}:host-context(.request-headers-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected *,\n  :host-context(.request-headers-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected.parent,\n  :host-context(.request-headers-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected.parent span,\n  :host-context(.request-headers-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected:focus .status-from-cache{color:HighlightText}}.header-decode-error{color:var(--color-accent-red)}.headers-title{display:flex;justify-content:space-between;width:100%;padding-right:5px}.tree-outline li .headers-link{display:none}.tree-outline li.expanded .headers-link{display:inline;color:var(--color-text-primary)}\n/*# sourceURL=requestHeadersTree.css */\n');const He=new CSSStyleSheet;He.replaceSync(".request-headers-view{user-select:text;overflow:auto}.resource-status-image{margin-top:-2px;margin-right:3px}.request-headers-tree{flex-grow:1;overflow-y:auto;margin:0;background-color:var(--color-background)}\n/*# sourceURL=requestHeadersView.css */\n");const Pe={general:"General",copyValue:"Copy value",learnMoreInTheIssuesTab:"Learn more in the issues tab",learnMore:"Learn more",requestUrl:"Request URL",showMore:"Show more",viewParsed:"View parsed",viewSource:"View source",requestHeaders:"Request Headers",responseHeaders:"Response Headers",statusCode:"Status Code",requestMethod:"Request Method",fromMemoryCache:"(from memory cache)",fromServiceWorker:"(from `service worker`)",fromSignedexchange:"(from signed-exchange)",fromPrefetchCache:"(from prefetch cache)",fromDiskCache:"(from disk cache)",fromWebBundle:"(from Web Bundle)",provisionalHeadersAreShownS:"Provisional headers are shown. Disable cache to see full headers.",onlyProvisionalHeadersAre:"Only provisional headers are available because this request was not sent over the network and instead was served from a local cache, which doesn’t store the original request headers. Disable cache to see full request headers.",provisionalHeadersAreShown:"Provisional headers are shown",activeClientExperimentVariation:"Active `client experiment variation IDs`.",activeClientExperimentVariationIds:"Active `client experiment variation IDs` that trigger server-side behavior.",decoded:"Decoded:",remoteAddress:"Remote Address",referrerPolicy:"Referrer Policy",toEmbedThisFrameInYourDocument:"To embed this frame in your document, the response needs to enable the cross-origin embedder policy by specifying the following response header:",toUseThisResourceFromADifferent:"To use this resource from a different origin, the server needs to specify a cross-origin resource policy in the response headers:",chooseThisOptionIfTheResourceAnd:"Choose this option if the resource and the document are served from the same site.",onlyChooseThisOptionIfAn:"Only choose this option if an arbitrary website including this resource does not impose a security risk.",thisDocumentWasBlockedFrom:"This document was blocked from loading in an `iframe` with a `sandbox` attribute because this document specified a cross-origin opener policy.",toUseThisResourceFromADifferentSite:"To use this resource from a different site, the server may relax the cross-origin resource policy response header:",toUseThisResourceFromADifferentOrigin:"To use this resource from a different origin, the server may relax the cross-origin resource policy response header:",headerOverrides:"Header overrides"},Ee=r.i18n.registerUIStrings("panels/network/RequestHeadersView.ts",Pe),Me=r.i18n.getLocalizedString.bind(void 0,Ee),Ue=r.i18n.getLazilyComputedLocalizedString.bind(void 0,Ee);class Ne extends o.Widget.VBox{request;showRequestHeadersText;showResponseHeadersText;highlightedElement;root;urlItem;requestMethodItem;statusCodeItem;remoteAddressItem;referrerPolicyItem;responseHeadersCategory;requestHeadersCategory;#t=p.Workspace.WorkspaceImpl.instance();constructor(e){super(),this.element.classList.add("request-headers-view"),this.request=e,this.showRequestHeadersText=!1,this.showResponseHeadersText=!1,this.highlightedElement=null;const t=new o.TreeOutline.TreeOutlineInShadow;t.registerCSSFiles([Le,qe,Fe]),t.element.classList.add("request-headers-tree"),t.makeDense(),t.setUseLightSelectionColor(!0),this.element.appendChild(t.element);const r=new Be(t,"general",Me(Pe.general));r.hidden=!1,this.root=r,this.setDefaultFocusedElement(this.root.listItemElement),this.urlItem=r.createLeaf(),this.requestMethodItem=r.createLeaf(),Ae.set(this.requestMethodItem,"Request-Method"),this.statusCodeItem=r.createLeaf(),Ae.set(this.statusCodeItem,"Status-Code"),this.remoteAddressItem=r.createLeaf(),this.remoteAddressItem.hidden=!0,this.referrerPolicyItem=r.createLeaf(),this.referrerPolicyItem.hidden=!0,this.responseHeadersCategory=new Be(t,"responseHeaders",""),this.requestHeadersCategory=new Be(t,"requestHeaders","")}wasShown(){this.clearHighlight(),this.registerCSSFiles([He]),this.request.addEventListener(s.NetworkRequest.Events.RemoteAddressChanged,this.refreshRemoteAddress,this),this.request.addEventListener(s.NetworkRequest.Events.RequestHeadersChanged,this.refreshRequestHeaders,this),this.request.addEventListener(s.NetworkRequest.Events.ResponseHeadersChanged,this.refreshResponseHeaders,this),this.request.addEventListener(s.NetworkRequest.Events.FinishedLoading,this.refreshHTTPInformation,this),this.#t.addEventListener(p.Workspace.Events.UISourceCodeAdded,this.#r,this),this.#t.addEventListener(p.Workspace.Events.UISourceCodeRemoved,this.#r,this),this.refreshURL(),this.refreshRequestHeaders(),this.refreshResponseHeaders(),this.refreshHTTPInformation(),this.refreshRemoteAddress(),this.refreshReferrerPolicy(),this.root.select(!0,!1)}willHide(){this.request.removeEventListener(s.NetworkRequest.Events.RemoteAddressChanged,this.refreshRemoteAddress,this),this.request.removeEventListener(s.NetworkRequest.Events.RequestHeadersChanged,this.refreshRequestHeaders,this),this.request.removeEventListener(s.NetworkRequest.Events.ResponseHeadersChanged,this.refreshResponseHeaders,this),this.request.removeEventListener(s.NetworkRequest.Events.FinishedLoading,this.refreshHTTPInformation,this),this.#t.removeEventListener(p.Workspace.Events.UISourceCodeAdded,this.#r,this),this.#t.removeEventListener(p.Workspace.Events.UISourceCodeRemoved,this.#r,this)}addEntryContextMenuHandler(e,r){e.listItemElement.addEventListener("contextmenu",(e=>{e.consume(!0);const i=new o.ContextMenu.ContextMenu(e),n=decodeURIComponent(r);i.clipboardSection().appendItem(Me(Pe.copyValue),(()=>{t.userMetrics.actionTaken(t.UserMetrics.Action.NetworkPanelCopyValue),t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(n)})),i.show()}))}formatHeader(e,t){const r=document.createDocumentFragment();return r.createChild("div","header-name").textContent=e+": ",r.createChild("span","header-separator"),r.createChild("div","header-value source-code").textContent=t,r}formatHeaderObject(e){const r=document.createDocumentFragment();e.headerNotSet&&(r.createChild("div","header-badge header-badge-text").textContent="not-set");const i=e.value?": ":"";if(r.createChild("div","header-name").textContent=e.name+i,r.createChild("span","header-separator"),e.value&&(e.headerValueIncorrect?r.createChild("div","header-value source-code header-warning").textContent=e.value.toString():r.createChild("div","header-value source-code").textContent=e.value.toString()),e.details){const i=r.createChild("div","header-details").createChild("div","call-to-action").createChild("div","call-to-action-body");i.createChild("div","explanation").textContent=e.details.explanation();for(const t of e.details.examples){const e=i.createChild("div","example");e.createChild("code").textContent=t.codeSnippet,t.comment&&(e.createChild("span","comment").textContent=t.comment())}if(S.RelatedIssue.hasIssueOfCategory(this.request,S.Issue.IssueCategory.CrossOriginEmbedderPolicy)){const e=document.createElement("div");e.classList.add("devtools-link"),e.onclick=()=>{t.userMetrics.issuesPanelOpenedFrom(t.UserMetrics.IssueOpener.LearnMoreLinkCOEP),S.RelatedIssue.reveal(this.request,S.Issue.IssueCategory.CrossOriginEmbedderPolicy)};const r=document.createElement("span");r.classList.add("devtools-link"),r.textContent=Me(Pe.learnMoreInTheIssuesTab),e.appendChild(r);const o=new k.Icon.Icon;o.data={iconName:"issue-exclamation-filled",color:"var(--icon-warning)",width:"20px",height:"20px"},e.prepend(o),i.appendChild(e)}else if(e.details.link){const t=o.XLink.XLink.create(e.details.link.url,Me(Pe.learnMore),"link"),r=new k.Icon.Icon;r.data={iconName:"open-externally",color:"var(--icon-default)",width:"20px",height:"20px"},t.prepend(r),i.appendChild(t)}}return r}refreshURL(){const e=this.request.url();this.urlItem.title=this.formatHeader(Me(Pe.requestUrl),e),this.addEntryContextMenuHandler(this.urlItem,e)}populateTreeElementWithSourceText(e,t){const r=(t||"").trim(),i=r.length>3e3,n=document.createElement("span");n.classList.add("header-value"),n.classList.add("source-code"),n.textContent=i?r.substr(0,3e3):r;const s=new o.TreeOutline.TreeElement(n);if(e.removeChildren(),e.appendChild(s),!i)return;const a=document.createElement("button");function l(){a.remove(),n.textContent=r,s.listItemElement.removeEventListener("contextmenu",d)}function d(e){const t=new o.ContextMenu.ContextMenu(e);t.newSection().appendItem(Me(Pe.showMore),l),t.show()}a.classList.add("request-headers-show-more-button"),a.textContent=Me(Pe.showMore),a.addEventListener("click",l),s.listItemElement.addEventListener("contextmenu",d),n.appendChild(a)}refreshRequestHeaders(){const e=this.requestHeadersCategory,t=this.request.requestHeaders().slice();t.sort((function(e,t){return n.StringUtilities.compare(e.name.toLowerCase(),t.name.toLowerCase())}));const r=this.request.requestHeadersText();if(this.showRequestHeadersText&&r?this.refreshHeadersText(Me(Pe.requestHeaders),t.length,r,e):this.refreshHeaders(Me(Pe.requestHeaders),t,e,!1,void 0===r),r){const t=this.createHeadersToggleButton(this.showRequestHeadersText);t.addEventListener("click",this.toggleRequestHeadersText.bind(this),!1),e.listItemElement.querySelector(".headers-title-left")?.appendChild(t)}}refreshResponseHeaders(){const e=this.responseHeadersCategory,t=this.request.sortedResponseHeaders.slice(),r=this.request.responseHeadersText;if(this.showResponseHeadersText)this.refreshHeadersText(Me(Pe.responseHeaders),t.length,r,e);else{const r=[];if(this.request.wasBlocked()){const e=Ve.get(this.request.blockedReason());e&&r.push(e)}const i=c.Runtime.experiments.isEnabled(c.Runtime.ExperimentName.HEADER_OVERRIDES);this.refreshHeaders(Me(Pe.responseHeaders),function(e,t){let r=0,i=0;const o=[];for(;r<e.length||i<t.length;)r<e.length&&(i>=t.length||e[r].name<t[i].name)?o.push({...e[r++],headerNotSet:!1}):i<t.length&&(r>=e.length||e[r].name>t[i].name)?o.push({...t[i++],headerNotSet:!0}):r<e.length&&i<t.length&&e[r].name===t[i].name&&o.push({...t[i++],...e[r++],headerNotSet:!1});return o}(t,r),e,i,!1,this.request.blockedResponseCookies())}if(r){const t=this.createHeadersToggleButton(this.showResponseHeadersText);t.addEventListener("click",this.toggleResponseHeadersText.bind(this),!1),e.listItemElement.querySelector(".headers-title-left")?.appendChild(t)}}refreshHTTPInformation(){const e=this.requestMethodItem;e.hidden=!this.request.statusCode;const t=this.statusCodeItem;if(t.hidden=!this.request.statusCode,this.request.statusCode){const r=document.createDocumentFragment();r.createChild("div","header-name").textContent=Me(Pe.statusCode)+": ",r.createChild("span","header-separator");const i=r.createChild("span","resource-status-image","dt-icon-label");o.Tooltip.Tooltip.install(i,this.request.statusCode+" "+this.request.statusText),this.request.statusCode<300||304===this.request.statusCode?i.data={iconName:"checkmark",color:"var(--icon-checkmark-green)",width:"14px",height:"14px"}:this.request.statusCode<400?i.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"}:i.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},e.title=this.formatHeader(Me(Pe.requestMethod),this.request.requestMethod);const n=r.createChild("div","header-value source-code");let s=this.request.statusCode+" "+this.request.statusText;this.request.cachedInMemory()?(s+=" "+Me(Pe.fromMemoryCache),n.classList.add("status-from-cache")):this.request.fetchedViaServiceWorker?(s+=" "+Me(Pe.fromServiceWorker),n.classList.add("status-from-cache")):this.request.redirectSourceSignedExchangeInfoHasNoErrors()?(s+=" "+Me(Pe.fromSignedexchange),n.classList.add("status-from-cache")):this.request.webBundleInnerRequestInfo()?(s+=" "+Me(Pe.fromWebBundle),n.classList.add("status-from-cache")):this.request.fromPrefetchCache()?(s+=" "+Me(Pe.fromPrefetchCache),n.classList.add("status-from-cache")):this.request.cached()&&(s+=" "+Me(Pe.fromDiskCache),n.classList.add("status-from-cache")),n.textContent=s,t.title=r}}refreshHeadersTitle(t,r,i,n){r.listItemElement.removeChildren(),r.listItemElement.createChild("div","selection fill");const s=r.listItemElement.createChild("div","headers-title"),a=s.createChild("div","headers-title-left");o.UIUtils.createTextChild(a,t);const l=` (${i})`;if(a.createChild("span","header-count").textContent=l,n&&this.#t.uiSourceCodeForURL(this.#i())){const t=e.Settings.Settings.instance().moduleSetting("persistenceNetworkOverridesEnabled"),r=new k.Icon.Icon;r.data={iconName:"document",color:"var(--icon-default)",width:"16px",height:"16px"},t.get()&&r.classList.add("dot","purple");const i=s.createChild("button","link devtools-link headers-link");i.appendChild(r),i.addEventListener("click",this.#o.bind(this));const o=document.createElement("span");o.textContent=Me(Pe.headerOverrides),i.appendChild(o)}}#i(){const e=T.NetworkPersistenceManager.NetworkPersistenceManager.instance().fileUrlFromNetworkUrl(this.request.url(),!0);return e.substring(0,e.lastIndexOf("/"))+"/"+T.NetworkPersistenceManager.HEADERS_FILENAME}#o(e){e.stopPropagation();const t=this.#t.uiSourceCodeForURL(this.#i());t&&x.SourcesPanel.SourcesPanel.instance().showUISourceCode(t)}#r(e){this.#i()===e.data.url()&&this.refreshResponseHeaders()}refreshHeaders(e,t,r,i,n,a){r.removeChildren();const l=t.length;if(this.refreshHeadersTitle(e,r,l,i),n){let e,t="";this.request.cachedInMemory()||this.request.cached()?(e=Me(Pe.provisionalHeadersAreShownS),t=Me(Pe.onlyProvisionalHeadersAre)):e=Me(Pe.provisionalHeadersAreShown);const i=document.createElement("div");i.classList.add("request-headers-caution"),o.Tooltip.Tooltip.install(i,t),i.createChild("span","","dt-icon-label").data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},i.createChild("div","caution").textContent=e;const n=new o.TreeOutline.TreeElement(i);i.createChild("div","learn-more").appendChild(o.XLink.XLink.create("https://developer.chrome.com/docs/devtools/network/reference/#provisional-headers",Me(Pe.learnMore))),r.appendChild(n)}const d=new Map;a&&a.forEach((e=>{d.set(e.cookieLine,e.blockedReasons)})),r.hidden=!l&&!n;for(const e of t){const t=new o.TreeOutline.TreeElement(this.formatHeaderObject(e));Ae.set(t,e.name);const i=e.name.toLowerCase();if("set-cookie"===i){const r=d.get(e.value);if(r){const e=new k.Icon.Icon;e.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},t.listItemElement.appendChild(e);let i="";for(const e of r)i&&(i+="\n"),i+=s.NetworkRequest.setCookieBlockedReasonToUiString(e);o.Tooltip.Tooltip.install(e,i)}}if(this.addEntryContextMenuHandler(t,e.value),r.appendChild(t),"x-client-data"===i){const r=y.parseClientVariations(e.value),i=y.formatClientVariations(r,Me(Pe.activeClientExperimentVariation),Me(Pe.activeClientExperimentVariationIds)),n=document.createElement("div");n.classList.add("x-client-data-details"),o.UIUtils.createTextChild(n,Me(Pe.decoded));const s=n.createChild("div");s.classList.add("source-code"),s.textContent=i,t.listItemElement.appendChild(n)}}}refreshHeadersText(e,t,r,i){this.populateTreeElementWithSourceText(i,r),this.refreshHeadersTitle(e,i,t,!1)}refreshRemoteAddress(){const e=this.request.remoteAddress(),t=this.remoteAddressItem;t.hidden=!e,e&&(t.title=this.formatHeader(Me(Pe.remoteAddress),e))}refreshReferrerPolicy(){const e=this.request.referrerPolicy(),t=this.referrerPolicyItem;t.hidden=!e,e&&(t.title=this.formatHeader(Me(Pe.referrerPolicy),e))}toggleRequestHeadersText(e){this.showRequestHeadersText=!this.showRequestHeadersText,this.refreshRequestHeaders(),e.consume()}toggleResponseHeadersText(e){this.showResponseHeadersText=!this.showResponseHeadersText,this.refreshResponseHeaders(),e.consume()}createToggleButton(e){const t=document.createElement("span");return t.classList.add("header-toggle"),t.textContent=e,t}createHeadersToggleButton(e){const t=Me(e?Pe.viewParsed:Pe.viewSource);return this.createToggleButton(t)}clearHighlight(){this.highlightedElement&&this.highlightedElement.listItemElement.classList.remove("header-highlight"),this.highlightedElement=null}revealAndHighlight(e,t){if(this.clearHighlight(),e){if(t)for(const r of e.children())if(Ae.get(r)?.toUpperCase()===t.toUpperCase())return this.highlightedElement=r,r.reveal(),void r.listItemElement.classList.add("header-highlight");e.childCount()>0&&e.childAt(0)?.reveal()}}getCategoryForSection(e){switch(e){case g.UIRequestLocation.UIHeaderSection.General:return this.root;case g.UIRequestLocation.UIHeaderSection.Request:return this.requestHeadersCategory;case g.UIRequestLocation.UIHeaderSection.Response:return this.responseHeadersCategory}}revealHeader(e,t){this.revealAndHighlight(this.getCategoryForSection(e),t)}}const Ae=new WeakMap;class Be extends o.TreeOutline.TreeElement{toggleOnClick;expandedSetting;expanded;constructor(t,r,i){super(i||"",!0),this.toggleOnClick=!0,this.hidden=!0,this.expandedSetting=e.Settings.Settings.instance().createSetting("request-info-"+r+"-category-expanded",!0),this.expanded=this.expandedSetting.get(),t.appendChild(this)}createLeaf(){const e=new o.TreeOutline.TreeElement;return this.appendChild(e),e}onexpand(){this.expandedSetting.set(!0)}oncollapse(){this.expandedSetting.set(!1)}}const Ve=new Map([["coep-frame-resource-needs-coep-header",{name:"cross-origin-embedder-policy",value:null,headerValueIncorrect:null,details:{explanation:Ue(Pe.toEmbedThisFrameInYourDocument),examples:[{codeSnippet:"Cross-Origin-Embedder-Policy: require-corp",comment:void 0}],link:{url:"https://web.dev/coop-coep/"}},headerNotSet:null}],["corp-not-same-origin-after-defaulted-to-same-origin-by-coep",{name:"cross-origin-resource-policy",value:null,headerValueIncorrect:null,details:{explanation:Ue(Pe.toUseThisResourceFromADifferent),examples:[{codeSnippet:"Cross-Origin-Resource-Policy: same-site",comment:Ue(Pe.chooseThisOptionIfTheResourceAnd)},{codeSnippet:"Cross-Origin-Resource-Policy: cross-origin",comment:Ue(Pe.onlyChooseThisOptionIfAn)}],link:{url:"https://web.dev/coop-coep/"}},headerNotSet:null}],["coop-sandboxed-iframe-cannot-navigate-to-coop-page",{name:"cross-origin-opener-policy",value:null,headerValueIncorrect:!1,details:{explanation:Ue(Pe.thisDocumentWasBlockedFrom),examples:[],link:{url:"https://web.dev/coop-coep/"}},headerNotSet:null}],["corp-not-same-site",{name:"cross-origin-resource-policy",value:null,headerValueIncorrect:!0,details:{explanation:Ue(Pe.toUseThisResourceFromADifferentSite),examples:[{codeSnippet:"Cross-Origin-Resource-Policy: cross-origin",comment:Ue(Pe.onlyChooseThisOptionIfAn)}],link:null},headerNotSet:null}],["corp-not-same-origin",{name:"cross-origin-resource-policy",value:null,headerValueIncorrect:!0,details:{explanation:Ue(Pe.toUseThisResourceFromADifferentOrigin),examples:[{codeSnippet:"Cross-Origin-Resource-Policy: same-site",comment:Ue(Pe.chooseThisOptionIfTheResourceAnd)},{codeSnippet:"Cross-Origin-Resource-Policy: cross-origin",comment:Ue(Pe.onlyChooseThisOptionIfAn)}],link:null},headerNotSet:null}]]);var We=Object.freeze({__proto__:null,RequestHeadersView:Ne,Category:Be});const Oe=new CSSStyleSheet;Oe.replaceSync(".tree-outline{padding-left:0;--override-error-background-color:#d93025;--override-error-text-color:#fff;--override-call-to-action-border-color:#f29900;--override-header-highlight-background-color:#ffff78}.-theme-with-dark-background .tree-outline,\n:host-context(.-theme-with-dark-background) .tree-outline{--override-error-text-color:#000;--override-call-to-action-border-color:rgb(255 166 13);--override-header-highlight-background-color:rgb(135 135 0)}.tree-outline > ol{padding-bottom:5px;border-bottom:solid 1px var(--color-details-hairline)}.tree-outline > .parent{user-select:none;font-weight:bold;color:var(--color-text-primary);margin-top:-1px;display:flex;align-items:center;height:26px}.tree-outline li{padding-left:5px;line-height:20px}.tree-outline li:not(.parent){margin-left:10px;display:block}.tree-outline li:not(.parent)::before{display:none}.tree-outline li.expanded .payload-count{display:none}.tree-outline li .payload-toggle{display:none}.tree-outline li.expanded .payload-toggle{display:inline;margin-left:30px;font-weight:normal;color:var(--color-text-primary)}.tree-outline li.expanded .payload-toggle:focus-visible{border:2px solid var(--color-button-outline-focus);border-radius:5px}.tree-outline li .header-toggle:hover{color:var(--color-text-secondary)}.tree-outline .payload-name{color:var(--color-text-secondary);display:inline-flex;margin-right:0.25em;font-weight:bold;vertical-align:top;white-space:pre-wrap}.tree-outline .payload-separator{user-select:none}.tree-outline .payload-value{display:inline;margin-right:1em;white-space:pre-wrap;word-break:break-all;margin-top:1px}.tree-outline .empty-request-payload{color:var(--color-text-disabled)}.request-payload-show-more-button{border:none;border-radius:3px;display:inline-block;font-size:12px;font-family:sans-serif;margin:0 4px;padding:2px 4px}@media (forced-colors: active){:host-context(.request-payload-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected:focus{background:Highlight}:host-context(.request-payload-tree) ol.tree-outline:not(.hide-selection-when-blurred) li::before{background-color:ButtonText}:host-context(.request-payload-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected.parent::before{background-color:HighlightText}:host-context(.request-payload-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected *,\n  :host-context(.request-payload-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected.parent,\n  :host-context(.request-payload-tree) ol.tree-outline:not(.hide-selection-when-blurred) li.selected.parent span{color:HighlightText}}.payload-decode-error{color:var(--color-accent-red)}\n/*# sourceURL=requestPayloadTree.css */\n");const De=new CSSStyleSheet;De.replaceSync(".request-payload-view{user-select:text;overflow:auto}.request-payload-tree{flex-grow:1;overflow-y:auto;margin:0}\n/*# sourceURL=requestPayloadView.css */\n");const Ge={copyValue:"Copy value",requestPayload:"Request Payload",unableToDecodeValue:"(unable to decode value)",queryStringParameters:"Query String Parameters",formData:"Form Data",showMore:"Show more",viewParsed:"View parsed",empty:"(empty)",viewSource:"View source",viewUrlEncoded:"View URL-encoded",viewDecoded:"View decoded",viewUrlEncodedL:"view URL-encoded",viewDecodedL:"view decoded",viewParsedL:"view parsed",viewSourceL:"view source"},ze=r.i18n.registerUIStrings("panels/network/RequestPayloadView.ts",Ge),_e=r.i18n.getLocalizedString.bind(void 0,ze);class je extends o.Widget.VBox{request;decodeRequestParameters;queryStringCategory;formDataCategory;requestPayloadCategory;constructor(e){super(),this.element.classList.add("request-payload-view"),this.request=e,this.decodeRequestParameters=!0;const t=e.requestContentType();t&&(this.decodeRequestParameters=Boolean(t.match(/^application\/x-www-form-urlencoded\s*(;.*)?$/i)));const r=new o.TreeOutline.TreeOutlineInShadow;r.registerCSSFiles([Le,qe,Oe]),r.element.classList.add("request-payload-tree"),r.makeDense(),this.element.appendChild(r.element),this.queryStringCategory=new $e(r,"queryString",""),this.formDataCategory=new $e(r,"formData",""),this.requestPayloadCategory=new $e(r,"requestPayload",_e(Ge.requestPayload))}wasShown(){this.registerCSSFiles([De]),this.request.addEventListener(s.NetworkRequest.Events.RequestHeadersChanged,this.refreshFormData,this),this.refreshQueryString(),this.refreshFormData()}willHide(){this.request.removeEventListener(s.NetworkRequest.Events.RequestHeadersChanged,this.refreshFormData,this)}addEntryContextMenuHandler(e,r){e.listItemElement.addEventListener("contextmenu",(e=>{e.consume(!0);const i=new o.ContextMenu.ContextMenu(e),n=decodeURIComponent(r);i.clipboardSection().appendItem(_e(Ge.copyValue),(()=>{t.userMetrics.actionTaken(t.UserMetrics.Action.NetworkPanelCopyValue),t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(n)})),i.show()}))}formatParameter(e,t,r){let i=!1;if(r&&(e=e.replace(/\+/g," ")).indexOf("%")>=0)try{e=decodeURIComponent(e)}catch(e){i=!0}const o=document.createElement("div");return t&&(o.className=t),""===e&&o.classList.add("empty-value"),i?o.createChild("span","payload-decode-error").textContent=_e(Ge.unableToDecodeValue):o.textContent=e,o}refreshQueryString(){const e=this.request.queryString(),t=this.request.queryParameters;this.queryStringCategory.hidden=!t,t&&this.refreshParams(_e(Ge.queryStringParameters),t,e,this.queryStringCategory)}async refreshFormData(){const e=await this.request.requestFormData();if(!e)return this.formDataCategory.hidden=!0,void(this.requestPayloadCategory.hidden=!0);const t=await this.request.formParameters();if(t)this.formDataCategory.hidden=!1,this.requestPayloadCategory.hidden=!0,this.refreshParams(_e(Ge.formData),t,e,this.formDataCategory);else{this.requestPayloadCategory.hidden=!1,this.formDataCategory.hidden=!0;try{const t=JSON.parse(e);this.refreshRequestJSONPayload(t,e)}catch(t){this.populateTreeElementWithSourceText(this.requestPayloadCategory,e)}}}populateTreeElementWithSourceText(e,t){const r=(t||"").trim(),i=r.length>3e3,n=document.createElement("span");n.classList.add("payload-value"),n.classList.add("source-code"),n.textContent=i?r.substr(0,3e3):r;const s=new o.TreeOutline.TreeElement(n);if(e.removeChildren(),e.appendChild(s),!i)return;const a=document.createElement("button");function l(){a.remove(),n.textContent=r,s.listItemElement.removeEventListener("contextmenu",d)}function d(e){const t=new o.ContextMenu.ContextMenu(e);t.newSection().appendItem(_e(Ge.showMore),l),t.show()}a.classList.add("request-payload-show-more-button"),a.textContent=_e(Ge.showMore),a.addEventListener("click",l),s.listItemElement.addEventListener("contextmenu",d),n.appendChild(a)}refreshParams(e,t,r,i){i.removeChildren(),i.listItemElement.removeChildren(),i.listItemElement.createChild("div","selection fill"),o.UIUtils.createTextChild(i.listItemElement,e);const n=document.createElement("span");n.classList.add("payload-count");const s=t?t.length:0;n.textContent=` (${s})`,i.listItemElement.appendChild(n);Ke.has(i)?this.appendParamsSource(e,t,r,i):this.appendParamsParsed(e,t,r,i)}appendParamsSource(e,t,r,i){this.populateTreeElementWithSourceText(i,r);const n=i.listItemElement,s=function(o){n.removeEventListener("contextmenu",a),Ke.delete(i),this.refreshParams(e,t,r,i),o.consume()},a=e=>{if(!i.expanded)return;const t=new o.ContextMenu.ContextMenu(e);t.newSection().appendItem(_e(Ge.viewParsed),s.bind(this,e)),t.show()},l=this.createViewSourceToggle(!0,s.bind(this));n.appendChild(l),n.addEventListener("contextmenu",a)}appendParamsParsed(e,t,r,i){for(const e of t||[]){const t=document.createDocumentFragment();if(""!==e.name){const r=this.formatParameter(e.name+": ","payload-name",this.decodeRequestParameters),i=this.formatParameter(e.value,"payload-value source-code",this.decodeRequestParameters);t.appendChild(r),t.createChild("span","payload-separator"),t.appendChild(i)}else t.appendChild(this.formatParameter(_e(Ge.empty),"empty-request-payload",this.decodeRequestParameters));const r=new o.TreeOutline.TreeElement(t);this.addEntryContextMenuHandler(r,e.value),i.appendChild(r)}const n=i.listItemElement,s=function(o){n.removeEventListener("contextmenu",l),Ke.add(i),this.refreshParams(e,t,r,i),o.consume()},a=function(e){n.removeEventListener("contextmenu",l),this.toggleURLDecoding(e)},l=e=>{if(!i.expanded)return;const t=new o.ContextMenu.ContextMenu(e),r=t.newSection();r.appendItem(_e(Ge.viewSource),s.bind(this,e));const n=this.decodeRequestParameters?_e(Ge.viewUrlEncoded):_e(Ge.viewDecoded);r.appendItem(n,a.bind(this,e)),t.show()},d=this.createViewSourceToggle(!1,s.bind(this));n.appendChild(d);const c=this.decodeRequestParameters?_e(Ge.viewUrlEncodedL):_e(Ge.viewDecodedL),h=this.createToggleButton(c);h.addEventListener("click",a.bind(this),!1),n.appendChild(h),n.addEventListener("contextmenu",l)}refreshRequestJSONPayload(e,t){const r=this.requestPayloadCategory;r.removeChildren();const i=r.listItemElement;i.removeChildren(),i.createChild("div","selection fill"),o.UIUtils.createTextChild(i,this.requestPayloadCategory.title.toString()),Ke.has(r)?this.appendJSONPayloadSource(r,e,t):this.appendJSONPayloadParsed(r,e,t)}appendJSONPayloadSource(e,t,r){const i=e.listItemElement;this.populateTreeElementWithSourceText(e,r);const n=function(o){i.removeEventListener("contextmenu",a),Ke.delete(e),this.refreshRequestJSONPayload(t,r),o.consume()},s=this.createViewSourceToggle(!0,n.bind(this));i.appendChild(s);const a=t=>{if(!e.expanded)return;const r=new o.ContextMenu.ContextMenu(t);r.newSection().appendItem(_e(Ge.viewParsed),n.bind(this,t)),r.show()};i.addEventListener("contextmenu",a)}appendJSONPayloadParsed(e,t,r){const i=s.RemoteObject.RemoteObject.fromLocalObject(t),n=new R.ObjectPropertiesSection.RootElement(i);n.title=i.description,n.expand(),n.editable=!1,e.childrenListElement.classList.add("source-code","object-properties-section"),e.appendChild(n);const a=e.listItemElement,l=function(i){a.removeEventListener("contextmenu",d),Ke.add(e),this.refreshRequestJSONPayload(t,r),i.consume()},d=t=>{if(!e.expanded)return;const r=new o.ContextMenu.ContextMenu(t);r.newSection().appendItem(_e(Ge.viewSource),l.bind(this,t)),r.show()},c=this.createViewSourceToggle(!1,l.bind(this));a.appendChild(c),a.addEventListener("contextmenu",d)}createViewSourceToggle(e,t){const r=_e(e?Ge.viewParsedL:Ge.viewSourceL),i=this.createToggleButton(r);return i.addEventListener("click",t,!1),i}toggleURLDecoding(e){this.decodeRequestParameters=!this.decodeRequestParameters,this.refreshQueryString(),this.refreshFormData(),e.consume()}createToggleButton(e){const t=document.createElement("span");return t.classList.add("payload-toggle"),t.tabIndex=0,t.setAttribute("role","button"),t.textContent=e,t}}const Ke=new WeakSet;class $e extends o.TreeOutline.TreeElement{toggleOnClick;expandedSetting;expanded;constructor(t,r,i){super(i||"",!0),this.toggleOnClick=!0,this.hidden=!0,this.expandedSetting=e.Settings.Settings.instance().createSetting("request-info-"+r+"-category-expanded",!0),this.expanded=this.expandedSetting.get(),t.appendChild(this)}createLeaf(){const e=new o.TreeOutline.TreeElement;return this.appendChild(e),e}onexpand(){this.expandedSetting.set(!0)}oncollapse(){this.expandedSetting.set(!1)}}var Xe=Object.freeze({__proto__:null,RequestPayloadView:je,Category:$e});const Je=new CSSStyleSheet;Je.replaceSync(".request-initiator-view{display:block;margin:6px}\n/*# sourceURL=requestInitiatorView.css */\n");const Ye=new CSSStyleSheet;Ye.replaceSync(".request-initiator-view-tree .fill{right:-6px}.request-initiator-view-section-title{font-weight:bold;padding:4px}.request-initiator-view-section-title:focus-visible{background-color:var(--color-background-elevation-2)}@media (forced-colors: active){.request-initiator-view-section-title:focus-visible{forced-color-adjust:none;background-color:Highlight;color:HighlightText}}\n/*# sourceURL=requestInitiatorViewTree.css */\n");const Qe={thisRequestHasNoInitiatorData:"This request has no initiator data.",requestCallStack:"Request call stack",requestInitiatorChain:"Request initiator chain"},Ze=r.i18n.registerUIStrings("panels/network/RequestInitiatorView.ts",Qe),et=r.i18n.getLocalizedString.bind(void 0,Ze);class tt extends o.Widget.VBox{linkifier;request;emptyWidget;hasShown;constructor(e){super(),this.element.classList.add("request-initiator-view"),this.linkifier=new w.Linkifier.Linkifier,this.request=e,this.emptyWidget=new o.EmptyWidget.EmptyWidget(et(Qe.thisRequestHasNoInitiatorData)),this.emptyWidget.show(this.element),this.hasShown=!1}static createStackTracePreview(e,t,r){const i=e.initiator();if(!i||!i.stack)return null;const o=s.NetworkManager.NetworkManager.forRequest(e),n=o?o.target():null;return w.JSPresentationUtils.buildStackTracePreviewContents(n,t,{stackTrace:i.stack,tabStops:r})}createTree(){const e=new o.TreeOutline.TreeOutlineInShadow;return e.registerCSSFiles([Ye]),e.contentElement.classList.add("request-initiator-view-tree"),e}buildRequestChainTree(e,t,r){const i=new o.TreeOutline.TreeElement(t);r.appendChild(i),i.titleElement instanceof HTMLElement&&i.titleElement.classList.add("request-initiator-view-section-title");const n=e.initiators;let s=i;for(const e of Array.from(n).reverse()){const t=new o.TreeOutline.TreeElement(e.url());s.appendChild(t),s.expand(),s=t}i.expand(),s.select();const a=s.titleElement;a instanceof HTMLElement&&(a.style.fontWeight="bold");const l=e.initiated;return this.depthFirstSearchTreeBuilder(l,s,this.request),i}depthFirstSearchTreeBuilder(e,t,r){const i=new Set;i.add(this.request);for(const n of e.keys())if(e.get(n)===r){const r=new o.TreeOutline.TreeElement(n.url());t.appendChild(r),t.expand(),i.has(n)||(i.add(n),this.depthFirstSearchTreeBuilder(e,r,n))}}buildStackTraceSection(e,t,r){const i=new o.TreeOutline.TreeElement(t);r.appendChild(i),i.titleElement instanceof HTMLElement&&i.titleElement.classList.add("request-initiator-view-section-title");const n=new o.TreeOutline.TreeElement(e,!1);n.selectable=!1,i.appendChild(n),i.expand()}wasShown(){if(this.hasShown)return;this.registerCSSFiles([Je]);let e=!1;const t=this.createTree(),r=tt.createStackTracePreview(this.request,this.linkifier,!0);r&&(e=!0,this.buildStackTraceSection(r.element,et(Qe.requestCallStack),t));const i=u.NetworkLog.NetworkLog.instance().initiatorGraphForRequest(this.request);(i.initiators.size>1||i.initiated.size>1)&&(e=!0,this.buildRequestChainTree(i,et(Qe.requestInitiatorChain),t));const o=t.firstChild();o&&o.select(!0),e&&(this.element.appendChild(t.element),this.emptyWidget.hideWidget()),this.hasShown=!0}}var rt=Object.freeze({__proto__:null,RequestInitiatorView:tt});const it=new CSSStyleSheet;it.replaceSync(".html-preview-frame{--override-preview-frame-background:#fff;box-shadow:var(--drop-shadow);background:var(--override-preview-frame-background);flex-grow:1;margin:20px}\n/*# sourceURL=requestHTMLView.css */\n");class ot extends o.Widget.VBox{dataURL;constructor(e){super(!0),this.dataURL=encodeURI(e).replace(/#/g,"%23"),this.contentElement.classList.add("html","request-view")}wasShown(){this.createIFrame(),this.registerCSSFiles([it])}willHide(){this.contentElement.removeChildren()}createIFrame(){this.contentElement.removeChildren();const e=document.createElement("iframe");e.className="html-preview-frame",e.setAttribute("sandbox",""),e.setAttribute("csp","default-src 'none';style-src 'unsafe-inline'"),e.setAttribute("src",this.dataURL),e.tabIndex=-1,o.ARIAUtils.markAsPresentation(e),this.contentElement.appendChild(e)}}var nt=Object.freeze({__proto__:null,RequestHTMLView:ot});const st={thisRequestHasNoResponseData:"This request has no response data available.",failedToLoadResponseData:"Failed to load response data"},at=r.i18n.registerUIStrings("panels/network/RequestResponseView.ts",st),lt=r.i18n.getLocalizedString.bind(void 0,at);class dt extends o.Widget.VBox{request;contentViewPromise;constructor(e){super(),this.element.classList.add("request-view"),this.request=e,this.contentViewPromise=null}static hasTextContent(t,r){const i=t.mimeType||"";let o=e.ResourceType.ResourceType.fromMimeType(i);return o===e.ResourceType.resourceTypes.Other&&(o=t.contentType()),o===e.ResourceType.resourceTypes.Image?i.startsWith("image/svg"):!!o.isTextType()||!r.error&&(o===e.ResourceType.resourceTypes.Other&&(Boolean(r.content)&&!r.encoded))}static async sourceViewForRequest(r){let o=ct.get(r);if(void 0!==o)return o;const n=await r.contentData();if(!dt.hasTextContent(r,n))return ct.delete(r),null;const s=r.resourceType().canonicalMimeType()||r.mimeType,a=e.ResourceType.ResourceType.mediaTypeForMetrics(s,r.resourceType().isFromSourceMap(),I.TextUtils.isMinified(n.content??""));t.userMetrics.networkPanelResponsePreviewOpened(a);const l=c.Runtime.experiments.isEnabled("sourcesPrettyPrint");return o=i.ResourceSourceFrame.ResourceSourceFrame.createSearchableView(r,s,l),ct.set(r,o),o}wasShown(){this.doShowPreview()}doShowPreview(){return this.contentViewPromise||(this.contentViewPromise=this.showPreview()),this.contentViewPromise}async showPreview(){const e=await this.createPreview();return e.show(this.element),e}async createPreview(){const e=await this.request.contentData(),t=await dt.sourceViewForRequest(this.request);return e.content&&t||e.error?e.content&&t?t:e.error?new o.EmptyWidget.EmptyWidget(lt(st.failedToLoadResponseData)+": "+e.error):204===this.request.statusCode?new o.EmptyWidget.EmptyWidget(lt(st.thisRequestHasNoResponseData)):new o.EmptyWidget.EmptyWidget(lt(st.failedToLoadResponseData)):new o.EmptyWidget.EmptyWidget(lt(st.thisRequestHasNoResponseData))}async revealLine(e){const t=await this.doShowPreview();t instanceof i.ResourceSourceFrame.SearchableContainer&&t.revealPosition(e)}}const ct=new WeakMap;var ht=Object.freeze({__proto__:null,RequestResponseView:dt});const ut=new CSSStyleSheet;ut.replaceSync(".tree-outline{padding-left:0}.tree-outline > ol{padding-bottom:5px;border-bottom:solid 1px var(--color-details-hairline)}.tree-outline > .parent{user-select:none;font-weight:bold;color:var(--color-text-primary);margin-top:-1px;display:flex;align-items:center;height:26px}.tree-outline li{padding-left:5px;line-height:20px}.tree-outline li:not(.parent){display:block;margin-left:10px}.tree-outline li:not(.parent)::before{display:none}.tree-outline .header-name{color:var(--color-text-secondary);display:inline-block;margin-right:0.25em;font-weight:bold;vertical-align:top;white-space:pre-wrap}.tree-outline .header-separator{user-select:none}.tree-outline .header-value{display:inline;margin-right:1em;white-space:pre-wrap;word-break:break-all;margin-top:1px}.tree-outline .header-toggle{display:inline;margin-left:30px;font-weight:normal;color:var(--color-text-disabled)}.tree-outline .header-toggle:hover{--override-header-hover-color:rgb(20% 20% 45%);color:var(--override-header-hover-color)}.-theme-with-dark-background .tree-outline .header-toggle:hover,\n:host-context(.-theme-with-dark-background) .tree-outline .header-toggle:hover{--override-header-hover-color:rgb(140 140 204)}.tree-outline .error-log{color:var(--color-red);display:inline-block;margin-right:0.25em;margin-left:0.25em;font-weight:bold;vertical-align:top;white-space:pre-wrap}.tree-outline .hex-data{display:block;word-break:break-word;margin-left:20px}.tree-outline .error-field{color:var(--color-red)}.prompt-icon{margin-top:2px}\n/*# sourceURL=signedExchangeInfoTree.css */\n");const pt=new CSSStyleSheet;pt.replaceSync(".signed-exchange-info-view{user-select:text;overflow:auto}.signed-exchange-info-tree{flex-grow:1;overflow-y:auto;margin:0}\n/*# sourceURL=signedExchangeInfoView.css */\n");const gt={errors:"Errors",signedHttpExchange:"Signed HTTP exchange",learnmore:"Learn more",requestUrl:"Request URL",responseCode:"Response code",headerIntegrityHash:"Header integrity hash",responseHeaders:"Response headers",signature:"Signature",label:"Label",certificateUrl:"Certificate URL",viewCertificate:"View certificate",integrity:"Integrity",certificateSha:"Certificate SHA256",validityUrl:"Validity URL",date:"Date",expires:"Expires",certificate:"Certificate",subject:"Subject",validFrom:"Valid from",validUntil:"Valid until",issuer:"Issuer"},mt=r.i18n.registerUIStrings("panels/network/SignedExchangeInfoView.ts",gt),wt=r.i18n.getLocalizedString.bind(void 0,mt);class vt extends o.Widget.VBox{responseHeadersItem;constructor(e){super(),console.assert(null!==e.signedExchangeInfo());const r=e.signedExchangeInfo();this.element.classList.add("signed-exchange-info-view");const i=new o.TreeOutline.TreeOutlineInShadow;i.registerCSSFiles([ut]),i.element.classList.add("signed-exchange-info-tree"),i.setFocusable(!1),i.makeDense(),i.expandTreeElementsWhenArrowing=!0,this.element.appendChild(i.element);const n=new Map;if(r.errors&&r.errors.length){const e=new kt(i,wt(gt.errors));for(const t of r.errors){const r=document.createDocumentFragment(),i=new k.Icon.Icon;if(i.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},i.classList.add("prompt-icon"),r.appendChild(i),r.createChild("div","error-log").textContent=t.message,e.createLeaf(r),t.errorField){let e=n.get(t.signatureIndex);e||(e=new Set,n.set(t.signatureIndex,e)),e.add(t.errorField)}}}const s=document.createDocumentFragment();s.createChild("div","header-name").textContent=wt(gt.signedHttpExchange);const a=o.XLink.XLink.create("https://github.com/WICG/webpackage",wt(gt.learnmore),"header-toggle");s.appendChild(a);const l=new kt(i,s);if(r.header){const s=r.header,a=e.redirectDestination(),d=this.formatHeader(wt(gt.requestUrl),s.requestUrl);if(a){const e=w.Linkifier.Linkifier.linkifyRevealable(a,"View request");e.classList.add("header-toggle"),d.appendChild(e)}l.createLeaf(d),l.createLeaf(this.formatHeader(wt(gt.responseCode),String(s.responseCode))),l.createLeaf(this.formatHeader(wt(gt.headerIntegrityHash),s.headerIntegrity)),this.responseHeadersItem=l.createLeaf(this.formatHeader(wt(gt.responseHeaders),""));const c=s.responseHeaders;for(const e in c){const t=new o.TreeOutline.TreeElement(this.formatHeader(e,c[e]));t.selectable=!1,this.responseHeadersItem.appendChild(t)}this.responseHeadersItem.expand();for(let e=0;e<s.signatures.length;++e){const r=n.get(e)||new Set,o=s.signatures[e],a=new kt(i,wt(gt.signature));if(a.createLeaf(this.formatHeader(wt(gt.label),o.label)),a.createLeaf(this.formatHeaderForHexData(wt(gt.signature),o.signature,r.has("signatureSig"))),o.certUrl){const e=this.formatHeader(wt(gt.certificateUrl),o.certUrl,r.has("signatureCertUrl"));if(o.certificates){const r=e.createChild("span","devtools-link header-toggle");r.textContent=wt(gt.viewCertificate),r.addEventListener("click",t.InspectorFrontendHost.InspectorFrontendHostInstance.showCertificateViewer.bind(null,o.certificates),!1)}a.createLeaf(e)}a.createLeaf(this.formatHeader(wt(gt.integrity),o.integrity,r.has("signatureIntegrity"))),o.certSha256&&a.createLeaf(this.formatHeaderForHexData(wt(gt.certificateSha),o.certSha256,r.has("signatureCertSha256"))),a.createLeaf(this.formatHeader(wt(gt.validityUrl),o.validityUrl,r.has("signatureValidityUrl"))),a.createLeaf().title=this.formatHeader(wt(gt.date),new Date(1e3*o.date).toUTCString(),r.has("signatureTimestamps")),a.createLeaf().title=this.formatHeader(wt(gt.expires),new Date(1e3*o.expires).toUTCString(),r.has("signatureTimestamps"))}}if(r.securityDetails){const e=r.securityDetails,t=new kt(i,wt(gt.certificate));t.createLeaf(this.formatHeader(wt(gt.subject),e.subjectName)),t.createLeaf(this.formatHeader(wt(gt.validFrom),new Date(1e3*e.validFrom).toUTCString())),t.createLeaf(this.formatHeader(wt(gt.validUntil),new Date(1e3*e.validTo).toUTCString())),t.createLeaf(this.formatHeader(wt(gt.issuer),e.issuer))}}formatHeader(e,t,r){const i=document.createDocumentFragment(),o=i.createChild("div","header-name");o.textContent=e+": ",i.createChild("span","header-separator");const n=i.createChild("div","header-value source-code");return n.textContent=t,r&&(o.classList.add("error-field"),n.classList.add("error-field")),i}formatHeaderForHexData(e,t,r){const i=document.createDocumentFragment(),o=i.createChild("div","header-name");o.textContent=e+": ",i.createChild("span","header-separator");const n=i.createChild("div","header-value source-code hex-data");return n.textContent=t.replace(/(.{2})/g,"$1 "),r&&(o.classList.add("error-field"),n.classList.add("error-field")),i}wasShown(){super.wasShown(),this.registerCSSFiles([pt])}}class kt extends o.TreeOutline.TreeElement{toggleOnClick;expanded;constructor(e,t){super(t,!0),this.selectable=!1,this.toggleOnClick=!0,this.expanded=!0,e.appendChild(this)}createLeaf(e){const t=new o.TreeOutline.TreeElement(e);return t.selectable=!1,this.appendChild(t),t}}var bt=Object.freeze({__proto__:null,SignedExchangeInfoView:vt,Category:kt});const ft=new CSSStyleSheet;ft.replaceSync(":host{--icon-padding:4px}.header{display:flex;font-weight:bold;padding:calc(2 * var(--icon-padding)) var(--icon-padding);line-height:20px}.icon{margin:0 var(--icon-padding)}\n/*# sourceURL=WebBundleInfoView.css */\n");const{render:Ct,html:St}=q,Tt={bundledResource:"Bundled resource"},yt=r.i18n.registerUIStrings("panels/network/components/WebBundleInfoView.ts",Tt),xt=r.i18n.getLocalizedString.bind(void 0,yt);class Rt extends b.LegacyWrapper.WrappableComponent{static litTagName=q.literal`devtools-web-bundle-info`;#n=this.attachShadow({mode:"open"});#s;#a;constructor(e){super();const t=e.webBundleInfo();if(!t)throw new Error("Trying to render a Web Bundle info without providing data");this.#s=t,this.#a=e.parsedURL.lastPathComponent}connectedCallback(){this.#n.adoptedStyleSheets=[ft]}async render(){const t=this.#s.resourceUrls?.map((t=>{const r=e.ResourceType.ResourceType.mimeFromURL(t)||null,i=e.ResourceType.ResourceType.fromMimeTypeOverride(r)||e.ResourceType.ResourceType.fromMimeType(r),o=v(i);return{cells:[{columnId:"url",value:null,renderer:()=>St` <div style="display: flex;"> <${k.Icon.Icon.litTagName} class="icon" .data="${{...o,width:"20px"}}"> </${k.Icon.Icon.litTagName}> <span>${t}</span> </div>`}]}}));Ct(St` <div class="header"> <${k.Icon.Icon.litTagName} class="icon" .data="${{color:"var(--icon-default)",iconName:"bundle",width:"20px"}}"> </${k.Icon.Icon.litTagName}> <span>${this.#a}</span> <x-link href="https://web.dev/web-bundles/#explaining-web-bundles"> <${k.Icon.Icon.litTagName} class="icon" .data="${{color:"var(--icon-default)",iconName:"help",width:"16px"}}"> </${k.Icon.Icon.litTagName}> </x-link> </div> <div> <${F.DataGrid.DataGrid.litTagName} .data="${{columns:[{id:"url",title:xt(Tt.bundledResource),widthWeighting:1,visible:!0,hideable:!1}],rows:t,activeSort:null}}"> </${F.DataGrid.DataGrid.litTagName}> </div>`,this.#n,{host:this})}}L.CustomElements.defineComponent("devtools-web-bundle-info",Rt);const It={failedToLoadResponseData:"Failed to load response data",previewNotAvailable:"Preview not available"},qt=r.i18n.registerUIStrings("panels/network/RequestPreviewView.ts",It),Lt=r.i18n.getLocalizedString.bind(void 0,qt);class Ft extends dt{constructor(e){super(e)}async showPreview(){const e=await super.showPreview();if(!(e instanceof o.View.SimpleView))return e;const t=new o.Toolbar.Toolbar("network-item-preview-toolbar",this.element);return e.toolbarItems().then((e=>{e.map((e=>t.appendToolbarItem(e)))})),e}async htmlPreview(){const e=await this.request.contentData();if(e.error)return new o.EmptyWidget.EmptyWidget(Lt(It.failedToLoadResponseData)+": "+e.error);if(!new Set(["text/html","text/plain","application/xhtml+xml"]).has(this.request.mimeType))return null;const t=e.encoded?window.atob(e.content):e.content,r=await i.JSONView.JSONView.createView(t);if(r)return r;const n=I.ContentProvider.contentAsDataURL(e.content,this.request.mimeType,e.encoded,this.request.charset());return n?new ot(n):null}async createPreview(){if(this.request.signedExchangeInfo())return new vt(this.request);if(this.request.webBundleInfo())return b.LegacyWrapper.legacyWrapper(o.Widget.VBox,new Rt(this.request));const e=await this.htmlPreview();if(e)return e;const t=await i.PreviewFactory.PreviewFactory.createPreview(this.request,this.request.mimeType);return t||new o.EmptyWidget.EmptyWidget(Lt(It.previewNotAvailable))}}var Ht=Object.freeze({__proto__:null,RequestPreviewView:Ft});const Pt={sLatencySDownloadSTotal:"{PH1} latency, {PH2} download ({PH3} total)",sLatency:"{PH1} latency",sDownload:"{PH1} download",sFromServiceworker:"{PH1} (from `ServiceWorker`)",sFromCache:"{PH1} (from cache)"},Et=r.i18n.registerUIStrings("panels/network/NetworkTimeCalculator.ts",Pt),Mt=r.i18n.getLocalizedString.bind(void 0,Et);class Ut{minimum;maximum;constructor(e,t){this.minimum=e,this.maximum=t}equals(e){return this.minimum===e.minimum&&this.maximum===e.maximum}}class Nt extends e.ObjectWrapper.ObjectWrapper{startAtZero;minimumBoundaryInternal;maximumBoundaryInternal;boundryChangedEventThrottler;window;workingArea;constructor(t){super(),this.startAtZero=t,this.minimumBoundaryInternal=-1,this.maximumBoundaryInternal=-1,this.boundryChangedEventThrottler=new e.Throttler.Throttler(0),this.window=null}setWindow(e){this.window=e,this.boundaryChanged()}setInitialUserFriendlyBoundaries(){this.minimumBoundaryInternal=0,this.maximumBoundaryInternal=1}computePosition(e){return(e-this.minimumBoundary())/this.boundarySpan()*(this.workingArea||0)}formatValue(e,t){return r.TimeUtilities.secondsToString(e,Boolean(t))}minimumBoundary(){return this.window?this.window.minimum:this.minimumBoundaryInternal}zeroTime(){return this.minimumBoundaryInternal}maximumBoundary(){return this.window?this.window.maximum:this.maximumBoundaryInternal}boundary(){return new Ut(this.minimumBoundary(),this.maximumBoundary())}boundarySpan(){return this.maximumBoundary()-this.minimumBoundary()}reset(){this.minimumBoundaryInternal=-1,this.maximumBoundaryInternal=-1,this.boundaryChanged()}value(){return 0}setDisplayWidth(e){this.workingArea=e}computeBarGraphPercentages(e){let t,r,i;return t=-1!==e.startTime?(e.startTime-this.minimumBoundary())/this.boundarySpan()*100:0,r=-1!==e.responseReceivedTime?(e.responseReceivedTime-this.minimumBoundary())/this.boundarySpan()*100:this.startAtZero?t:100,i=-1!==e.endTime?(e.endTime-this.minimumBoundary())/this.boundarySpan()*100:this.startAtZero?r:100,this.startAtZero&&(i-=t,r-=t,t=0),{start:t,middle:r,end:i}}computePercentageFromEventTime(e){return-1===e||this.startAtZero?0:(e-this.minimumBoundary())/this.boundarySpan()*100}percentageToTime(e){return e*this.boundarySpan()/100+this.minimumBoundary()}boundaryChanged(){this.boundryChangedEventThrottler.schedule((async()=>{this.dispatchEventToListeners(Bt.BoundariesChanged)}))}updateBoundariesForEventTime(e){-1===e||this.startAtZero||(void 0===this.maximumBoundaryInternal||e>this.maximumBoundaryInternal)&&(this.maximumBoundaryInternal=e,this.boundaryChanged())}computeBarGraphLabels(e){let t="";-1!==e.responseReceivedTime&&-1!==e.endTime&&(t=r.TimeUtilities.secondsToString(e.endTime-e.responseReceivedTime));const i=e.latency>0,o=i?r.TimeUtilities.secondsToString(e.latency):t;if(e.timing)return{left:o,right:t,tooltip:void 0};let n;if(i&&t){const i=r.TimeUtilities.secondsToString(e.duration);n=Mt(Pt.sLatencySDownloadSTotal,{PH1:o,PH2:t,PH3:i})}else i?n=Mt(Pt.sLatency,{PH1:o}):t&&(n=Mt(Pt.sDownload,{PH1:t}));return e.fetchedViaServiceWorker?n=Mt(Pt.sFromServiceworker,{PH1:String(n)}):e.cached()&&(n=Mt(Pt.sFromCache,{PH1:String(n)})),{left:o,right:t,tooltip:n}}updateBoundaries(e){const t=this.lowerBound(e),r=this.upperBound(e);let i=!1;(-1!==t||this.startAtZero)&&(i=this.extendBoundariesToIncludeTimestamp(this.startAtZero?0:t)),-1!==r&&(i=this.extendBoundariesToIncludeTimestamp(r)||i),i&&this.boundaryChanged()}extendBoundariesToIncludeTimestamp(e){const t=this.minimumBoundaryInternal,r=this.maximumBoundaryInternal,i=At;return-1===this.minimumBoundaryInternal||-1===this.maximumBoundaryInternal?(this.minimumBoundaryInternal=e,this.maximumBoundaryInternal=e+i):(this.minimumBoundaryInternal=Math.min(e,this.minimumBoundaryInternal),this.maximumBoundaryInternal=Math.max(e,this.minimumBoundaryInternal+i,this.maximumBoundaryInternal)),t!==this.minimumBoundaryInternal||r!==this.maximumBoundaryInternal}lowerBound(e){return 0}upperBound(e){return 0}}const At=.1;var Bt;!function(e){e.BoundariesChanged="BoundariesChanged"}(Bt||(Bt={}));class Vt extends Nt{constructor(){super(!1)}formatValue(e,t){return r.TimeUtilities.secondsToString(e-this.zeroTime(),Boolean(t))}lowerBound(e){return e.issueTime()}upperBound(e){return e.endTime}}class Wt extends Nt{constructor(){super(!0)}formatValue(e,t){return r.TimeUtilities.secondsToString(e,Boolean(t))}upperBound(e){return e.duration}}var Ot=Object.freeze({__proto__:null,NetworkTimeBoundary:Ut,NetworkTimeCalculator:Nt,_minimumSpread:At,get Events(){return Bt},NetworkTransferTimeCalculator:Vt,NetworkTransferDurationCalculator:Wt});const Dt=new CSSStyleSheet;Dt.replaceSync('.network-timing-table{width:380px;border-spacing:0;padding-left:10px;padding-right:10px;line-height:initial;table-layout:fixed}.network-timing-start{border-top:5px solid transparent}.network-timing-start th span.network-timing-hidden-header{height:1px;width:1px;position:absolute;overflow:hidden}.network-timing-table-header td,\n.network-timing-footer td{border-top:10px solid transparent}.network-timing-table-header td{color:var(--color-text-secondary)}.network-timing-table td{padding:4px 0}.network-timing-table-header td:last-child{text-align:right}.network-timing-footer td:last-child{font-weight:bold;text-align:right}table.network-timing-table > tr:not(.network-timing-table-header):not(.network-timing-footer) > td:first-child{padding-left:12px}.network-timing-table col.labels{width:156px}.network-timing-table col.duration{width:80px}.network-timing-table td.caution{font-weight:bold;color:var(--issue-color-yellow);padding:2px 0}.network-timing-table hr.break{border:0;height:1px;background-image:linear-gradient(to right,var(--color-background-elevation-0),var(--color-text-secondary),var(--color-background-elevation-0))}.network-timing-row{position:relative;height:15px}.network-timing-bar{position:absolute;min-width:1px;top:0;bottom:0}.network-timing-bar-title{color:var(--color-text-primary);white-space:nowrap;text-align:right}.network-timing-bar.queueing,\n.network-timing-bar.total{border:1px solid var(--color-text-secondary)}.network-timing-bar.blocking,\n.-theme-preserve{background-color:var(--override-network-overview-blocking)}.network-timing-bar.proxy,\n.-theme-preserve{background-color:var(--override-network-overview-proxy)}.network-timing-bar.dns,\n.-theme-preserve{background-color:var(--override-network-overview-dns)}.network-timing-bar.connecting,\n.network-timing-bar.serviceworker,\n.network-timing-bar.serviceworker-preparation,\n.-theme-preserve{background-color:var(--override-network-overview-service-worker)}.network-timing-bar.ssl,\n.-theme-preserve{background-color:var(--override-network-overview-ssl)}.network-timing-bar.serviceworker-respondwith,\n.-theme-preserve{background-color:var(--override-network-overview-service-worker-respond-with)}.network-fetch-timing-bar-clickable::before{user-select:none;-webkit-mask-image:var(--image-file-triangle-right);float:left;width:14px;height:14px;margin-right:2px;content:"";position:relative;top:3px;background-color:var(--icon-default);transition:transform 200ms}.network-fetch-timing-bar-clickable{position:relative;left:-12px}.network-fetch-timing-bar-clickable:focus-visible{background-color:var(--color-background-elevation-1)}.network-fetch-timing-bar-clickable[aria-checked="true"]::before{transform:rotate(90deg)}.network-fetch-timing-bar-details-collapsed{display:none}.network-fetch-timing-bar-details-expanded{display:block}.network-fetch-timing-bar-details{padding-left:11px;width:fit-content}.network-fetch-details-treeitem{width:max-content}.network-timing-bar.sending,\n.-theme-preserve{background-color:var(--override-network-overview-sending)}.network-timing-bar.waiting,\n.-theme-preserve{background-color:var(--override-network-overview-waiting)}.network-timing-bar.receiving,\n.network-timing-bar.receiving-push,\n.-theme-preserve{background-color:var(--override-network-overview-receiving)}.network-timing-bar.push,\n.-theme-preserve{background-color:var(--override-network-overview-push)}.server-timing-row:nth-child(even){background:var(--color-background-elevation-0)}.network-timing-bar.server-timing,\n.-theme-preserve{background-color:var(--color-background-elevation-2)}.network-timing-table td.network-timing-metric{white-space:nowrap;max-width:150px;overflow-x:hidden;text-overflow:ellipsis}.network-timing-bar.proxy,\n.network-timing-bar.dns,\n.network-timing-bar.ssl,\n.network-timing-bar.connecting,\n.network-timing-bar.blocking{height:10px;margin:auto}@media (forced-colors: active){.network-timing-bar.blocking,\n  .network-timing-bar.proxy,\n  .network-timing-bar.dns,\n  .network-timing-bar.connecting,\n  .network-timing-bar.serviceworker,\n  .network-timing-bar.serviceworker-preparation,\n  .network-timing-bar.ssl,\n  .network-timing-bar.sending,\n  .network-timing-bar.waiting,\n  .network-timing-bar.receiving,\n  .network-timing-bar.receiving-push,\n  .network-timing-bar.push,\n  .network-timing-bar.server-timing,\n  .-theme-preserve{forced-color-adjust:none}.network-timing-table-header td,\n  .network-timing-footer td{forced-color-adjust:none;color:ButtonText}}\n/*# sourceURL=networkTimingTable.css */\n');const Gt={receivingPush:"Receiving `Push`",queueing:"Queueing",stalled:"Stalled",initialConnection:"Initial connection",dnsLookup:"DNS Lookup",proxyNegotiation:"Proxy negotiation",readingPush:"Reading `Push`",contentDownload:"Content Download",requestSent:"Request sent",requestToServiceworker:"Request to `ServiceWorker`",startup:"Startup",respondwith:"respondWith",ssl:"SSL",total:"Total",waitingTtfb:"Waiting for server response",label:"Label",waterfall:"Waterfall",duration:"Duration",queuedAtS:"Queued at {PH1}",startedAtS:"Started at {PH1}",serverPush:"Server Push",resourceScheduling:"Resource Scheduling",connectionStart:"Connection Start",requestresponse:"Request/Response",cautionRequestIsNotFinishedYet:"CAUTION: request is not finished yet!",explanation:"Explanation",serverTiming:"Server Timing",time:"TIME",theServerTimingApi:"the Server Timing API",duringDevelopmentYouCanUseSToAdd:"During development, you can use {PH1} to add insights into the server-side timing of this request.",durationC:"DURATION",originalRequest:"Original Request",responseReceived:"Response Received",unknown:"Unknown",sourceOfResponseS:"Source of response: {PH1}",cacheStorageCacheNameS:"Cache storage cache name: {PH1}",cacheStorageCacheNameUnknown:"Cache storage cache name: Unknown",retrievalTimeS:"Retrieval Time: {PH1}",serviceworkerCacheStorage:"`ServiceWorker` cache storage",fromHttpCache:"From HTTP cache",networkFetch:"Network fetch",fallbackCode:"Fallback code"},zt=r.i18n.registerUIStrings("panels/network/RequestTimingView.ts",Gt),_t=r.i18n.getLocalizedString.bind(void 0,zt);class jt extends o.Widget.VBox{request;calculator;lastMinimumBoundary;tableElement;constructor(e,t){super(),this.element.classList.add("resource-timing-view"),this.request=e,this.calculator=t,this.lastMinimumBoundary=-1}static timeRangeTitle(e){switch(e){case Kt.Push:return _t(Gt.receivingPush);case Kt.Queueing:return _t(Gt.queueing);case Kt.Blocking:return _t(Gt.stalled);case Kt.Connecting:return _t(Gt.initialConnection);case Kt.DNS:return _t(Gt.dnsLookup);case Kt.Proxy:return _t(Gt.proxyNegotiation);case Kt.ReceivingPush:return _t(Gt.readingPush);case Kt.Receiving:return _t(Gt.contentDownload);case Kt.Sending:return _t(Gt.requestSent);case Kt.ServiceWorker:return _t(Gt.requestToServiceworker);case Kt.ServiceWorkerPreparation:return _t(Gt.startup);case Kt.ServiceWorkerRespondWith:return _t(Gt.respondwith);case Kt.SSL:return _t(Gt.ssl);case Kt.Total:return _t(Gt.total);case Kt.Waiting:return _t(Gt.waitingTtfb);default:return e}}static calculateRequestTimeRanges(e,t){const r=[];function i(e,t,i){t<Number.MAX_VALUE&&t<=i&&r.push({name:e,start:t,end:i})}function o(e){for(let t=0;t<e.length;++t)if(e[t]>0)return e[t]}function n(e,t,r){t>=0&&r>=0&&i(e,l+t/1e3,l+r/1e3)}const s=e.timing;if(!s){const t=-1!==e.issueTime()?e.issueTime():-1!==e.startTime?e.startTime:0,o=-1!==e.issueTime()&&-1!==e.startTime&&e.issueTime()!==e.startTime,n=-1===e.responseReceivedTime?o?e.startTime:Number.MAX_VALUE:e.responseReceivedTime,s=-1===e.endTime?Number.MAX_VALUE:e.endTime;i(Kt.Total,t,s),i(Kt.Blocking,t,n);return i(-1===e.responseReceivedTime?Kt.Connecting:Kt.Receiving,n,s),r}const a=e.issueTime(),l=s.requestTime,d=o([e.endTime,e.responseReceivedTime])||l;if(i(Kt.Total,a<l?a:l,d),s.pushStart){const e=s.pushEnd||d;e>t&&i(Kt.Push,Math.max(s.pushStart,t),e)}a<l&&i(Kt.Queueing,a,l);const c=1e3*(e.responseReceivedTime-l);if(e.fetchedViaServiceWorker)n(Kt.Blocking,0,s.workerStart),n(Kt.ServiceWorkerPreparation,s.workerStart,s.workerReady),n(Kt.ServiceWorkerRespondWith,s.workerFetchStart,s.workerRespondWithSettled),n(Kt.ServiceWorker,s.workerReady,s.sendEnd),n(Kt.Waiting,s.sendEnd,c);else if(!s.pushStart){const e=o([s.dnsStart,s.connectStart,s.sendStart,c])||0;n(Kt.Blocking,0,e),n(Kt.Proxy,s.proxyStart,s.proxyEnd),n(Kt.DNS,s.dnsStart,s.dnsEnd),n(Kt.Connecting,s.connectStart,s.connectEnd),n(Kt.SSL,s.sslStart,s.sslEnd),n(Kt.Sending,s.sendStart,s.sendEnd),n(Kt.Waiting,Math.max(s.sendEnd,s.connectEnd,s.dnsEnd,s.proxyEnd,e),c)}return-1!==e.endTime&&i(s.pushStart?Kt.ReceivingPush:Kt.Receiving,e.responseReceivedTime,d),r}static createTimingTable(t,i){const n=document.createElement("table");n.classList.add("network-timing-table");const s=n.createChild("colgroup");s.createChild("col","labels"),s.createChild("col","bars"),s.createChild("col","duration");const a=jt.calculateRequestTimeRanges(t,i.minimumBoundary()),l=a.map((e=>e.start)).reduce(((e,t)=>Math.min(e,t))),d=a.map((e=>e.end)).reduce(((e,t)=>Math.max(e,t))),c=100/(d-l);let h,u,p,g,m=0;const w=n.createChild("thead","network-timing-start"),v=w.createChild("tr"),k=v.createChild("th");k.createChild("span","network-timing-hidden-header").textContent=_t(Gt.label),k.scope="col";const b=v.createChild("th");b.createChild("span","network-timing-hidden-header").textContent=_t(Gt.waterfall),b.scope="col";const f=v.createChild("th");f.createChild("span","network-timing-hidden-header").textContent=_t(Gt.duration),f.scope="col";const C=w.createChild("tr").createChild("td"),S=w.createChild("tr").createChild("td");let T;C.colSpan=S.colSpan=3,o.UIUtils.createTextChild(C,_t(Gt.queuedAtS,{PH1:i.formatValue(t.issueTime(),2)})),o.UIUtils.createTextChild(S,_t(Gt.startedAtS,{PH1:i.formatValue(t.startTime,2)}));for(let e=0;e<a.length;++e){const t=a[e],s=t.name;if(s===Kt.Total){m=t.end-t.start;continue}s===Kt.Push?H(_t(Gt.serverPush)):s===Kt.Queueing?g||(g=H(_t(Gt.resourceScheduling))):Xt.has(s)?h||(h=H(_t(Gt.connectionStart))):$t.has(s)?u||(u=H("Service Worker")):p||(p=H(_t(Gt.requestresponse)));const w=c*(t.start-l);T=c*(d-t.end);const v=t.end-t.start,k=n.createChild("tr"),b=k.createChild("td");o.UIUtils.createTextChild(b,jt.timeRangeTitle(s));const f=k.createChild("td").createChild("div","network-timing-row"),C=f.createChild("span","network-timing-bar "+s);C.style.left=w+"%",C.style.right=T+"%",C.textContent="​",o.ARIAUtils.setLabel(f,_t(Gt.startedAtS,{PH1:i.formatValue(t.start,2)}));k.createChild("td").createChild("div","network-timing-bar-title").textContent=r.TimeUtilities.secondsToString(v,!0),"serviceworker-respondwith"===t.name&&(b.classList.add("network-fetch-timing-bar-clickable"),n.createChild("tr","network-fetch-timing-bar-details"),b.setAttribute("tabindex","0"),b.setAttribute("role","switch"),o.ARIAUtils.setChecked(b,!1))}if(!t.finished&&!t.preserved){const e=n.createChild("tr").createChild("td","caution");e.colSpan=3,o.UIUtils.createTextChild(e,_t(Gt.cautionRequestIsNotFinishedYet))}const y=n.createChild("tr","network-timing-footer"),x=y.createChild("td");x.colSpan=1,x.appendChild(o.XLink.XLink.create("https://developer.chrome.com/docs/devtools/network/reference/#timing-explanation",_t(Gt.explanation))),y.createChild("td"),o.UIUtils.createTextChild(y.createChild("td"),r.TimeUtilities.secondsToString(m,!0));const R=t.serverTimings,I=void 0===T?100:T,q=n.createChild("tr","network-timing-table-header").createChild("td");q.colSpan=3,q.createChild("hr","break");const L=n.createChild("tr","network-timing-table-header");if(o.UIUtils.createTextChild(L.createChild("td"),_t(Gt.serverTiming)),L.createChild("td"),o.UIUtils.createTextChild(L.createChild("td"),_t(Gt.time)),!R){const e=n.createChild("tr").createChild("td");e.colSpan=3;const t=o.XLink.XLink.create("https://web.dev/custom-metrics/#server-timing-api",_t(Gt.theServerTimingApi));return e.appendChild(r.i18n.getFormatLocalizedString(zt,Gt.duringDevelopmentYouCanUseSToAdd,{PH1:t})),n}return R.filter((e=>"total"!==e.metric.toLowerCase())).forEach((e=>F(e,I))),R.filter((e=>"total"===e.metric.toLowerCase())).forEach((e=>F(e,I))),n;function F(t,i){const s=new e.Color.Generator({min:0,max:360,count:36},{min:50,max:80,count:void 0},80),a="total"===t.metric.toLowerCase(),h=n.createChild("tr",a?"network-timing-footer":"server-timing-row"),u=h.createChild("td","network-timing-metric"),p=t.description||t.metric;o.UIUtils.createTextChild(u,p),o.Tooltip.Tooltip.install(u,p);const g=h.createChild("td").createChild("div","network-timing-row");if(null===t.value)return;const m=c*(d-l-t.value/1e3);if(m>=0){const e=g.createChild("span","network-timing-bar server-timing");e.style.left=m+"%",e.style.right=i+"%",e.textContent="​",a||(e.style.backgroundColor=s.colorForID(t.metric))}h.createChild("td").createChild("div","network-timing-bar-title").textContent=r.TimeUtilities.millisToString(t.value,!0)}function H(e){const t=n.createChild("tr","network-timing-table-header"),r=t.createChild("td");return o.UIUtils.createTextChild(r,e),o.ARIAUtils.markAsHeading(r,2),o.UIUtils.createTextChild(t.createChild("td"),""),o.UIUtils.createTextChild(t.createChild("td"),_t(Gt.durationC)),t}}constructFetchDetailsView(){if(!this.tableElement)return;const e=this.tableElement.ownerDocument,t=e.querySelector(".network-fetch-timing-bar-details");if(!t)return;t.classList.add("network-fetch-timing-bar-details-collapsed"),self.onInvokeElement(this.tableElement,this.onToggleFetchDetails.bind(this,t));const r=new o.TreeOutline.TreeOutlineInShadow;t.appendChild(r.element);const i=u.NetworkLog.NetworkLog.instance().originalRequestForURL(this.request.url());if(i){const e=s.RemoteObject.RemoteObject.fromLocalObject(i),t=new R.ObjectPropertiesSection.RootElement(e);t.title=_t(Gt.originalRequest),r.appendChild(t)}const n=u.NetworkLog.NetworkLog.instance().originalResponseForURL(this.request.url());if(n){const e=s.RemoteObject.RemoteObject.fromLocalObject(n),t=new R.ObjectPropertiesSection.RootElement(e);t.title=_t(Gt.responseReceived),r.appendChild(t)}const a=e.createElement("div");a.classList.add("network-fetch-details-treeitem");let l=_t(Gt.unknown);const d=this.request.serviceWorkerResponseSource();d&&(l=this.getLocalizedResponseSourceForCode(d)),a.textContent=_t(Gt.sourceOfResponseS,{PH1:l});const c=new o.TreeOutline.TreeElement(a);r.appendChild(c);const h=e.createElement("div");h.classList.add("network-fetch-details-treeitem");const p=this.request.getResponseCacheStorageCacheName();h.textContent=p?_t(Gt.cacheStorageCacheNameS,{PH1:p}):_t(Gt.cacheStorageCacheNameUnknown);const g=new o.TreeOutline.TreeElement(h);r.appendChild(g);const m=this.request.getResponseRetrievalTime();if(m){const t=e.createElement("div");t.classList.add("network-fetch-details-treeitem"),t.textContent=_t(Gt.retrievalTimeS,{PH1:m.toString()});const i=new o.TreeOutline.TreeElement(t);r.appendChild(i)}}getLocalizedResponseSourceForCode(e){switch(e){case"cache-storage":return _t(Gt.serviceworkerCacheStorage);case"http-cache":return _t(Gt.fromHttpCache);case"network":return _t(Gt.networkFetch);default:return _t(Gt.fallbackCode)}}onToggleFetchDetails(e,r){if(!r.target)return;const i=r.target;if(i.classList.contains("network-fetch-timing-bar-clickable")){e.classList.contains("network-fetch-timing-bar-details-collapsed")&&t.userMetrics.actionTaken(t.UserMetrics.Action.NetworkPanelServiceWorkerRespondWith);const r="true"===i.getAttribute("aria-checked");i.setAttribute("aria-checked",String(!r)),e.classList.toggle("network-fetch-timing-bar-details-collapsed"),e.classList.toggle("network-fetch-timing-bar-details-expanded")}}wasShown(){this.request.addEventListener(s.NetworkRequest.Events.TimingChanged,this.refresh,this),this.request.addEventListener(s.NetworkRequest.Events.FinishedLoading,this.refresh,this),this.calculator.addEventListener(Bt.BoundariesChanged,this.boundaryChanged,this),this.registerCSSFiles([Dt]),this.refresh()}willHide(){this.request.removeEventListener(s.NetworkRequest.Events.TimingChanged,this.refresh,this),this.request.removeEventListener(s.NetworkRequest.Events.FinishedLoading,this.refresh,this),this.calculator.removeEventListener(Bt.BoundariesChanged,this.boundaryChanged,this)}refresh(){this.tableElement&&this.tableElement.remove(),this.tableElement=jt.createTimingTable(this.request,this.calculator),this.tableElement.classList.add("resource-timing-table"),this.element.appendChild(this.tableElement),this.request.fetchedViaServiceWorker&&this.constructFetchDetailsView()}boundaryChanged(){const e=this.calculator.minimumBoundary();e!==this.lastMinimumBoundary&&(this.lastMinimumBoundary=e,this.refresh())}}var Kt;!function(e){e.Push="push",e.Queueing="queueing",e.Blocking="blocking",e.Connecting="connecting",e.DNS="dns",e.Proxy="proxy",e.Receiving="receiving",e.ReceivingPush="receiving-push",e.Sending="sending",e.ServiceWorker="serviceworker",e.ServiceWorkerPreparation="serviceworker-preparation",e.ServiceWorkerRespondWith="serviceworker-respondwith",e.SSL="ssl",e.Total="total",e.Waiting="waiting"}(Kt||(Kt={}));const $t=new Set([Kt.ServiceWorker,Kt.ServiceWorkerPreparation,Kt.ServiceWorkerRespondWith]),Xt=new Set([Kt.Queueing,Kt.Blocking,Kt.Connecting,Kt.DNS,Kt.Proxy,Kt.SSL]);var Jt=Object.freeze({__proto__:null,RequestTimingView:jt,get RequestTimeRangeNames(){return Kt},ServiceWorkerRangeNames:$t,ConnectionSetupRangeNames:Xt});const Yt=new CSSStyleSheet;Yt.replaceSync('.websocket-frame-view{--override-icon-color-when-row-selected:#fff;--override-send-row-background-color:rgb(226 247 218);--override-error-row-background-color:rgb(255 237 237);user-select:text}.-theme-with-dark-background .websocket-frame-view,\n:host-context(.-theme-with-dark-background) .websocket-frame-view{--override-icon-color-when-row-selected:#000;--override-send-row-background-color:rgb(16 37 8);--override-error-row-background-color:rgb(18 0 0)}.websocket-frame-view .data-grid{flex:auto;border:none}.websocket-frame-view .data-grid .data{background-image:none}.websocket-frame-view-td{border-bottom:1px solid var(--color-details-hairline)}.websocket-frame-view .data-grid td,\n.websocket-frame-view .data-grid th{border-left-color:var(--color-details-hairline)}.websocket-frame-view-row-send td:first-child::before{content:"\\2B06";color:var(--color-green);padding-right:4px}.websocket-frame-view-row-receive td:first-child::before{content:"\\2B07";color:var(--color-red);padding-right:4px}.data-grid:focus .websocket-frame-view-row-send.selected td:first-child::before,\n.data-grid:focus .websocket-frame-view-row-receive.selected td:first-child::before{color:var(--override-icon-color-when-row-selected)}.websocket-frame-view-row-send{background-color:var(--override-send-row-background-color)}.websocket-frame-view-row-error{background-color:var(--override-error-row-background-color);color:var(--color-accent-red)}.websocket-frame-view .toolbar{border-bottom:var(--legacy-divider-border)}\n/*# sourceURL=webSocketFrameView.css */\n');const Qt={data:"Data",length:"Length",time:"Time",webSocketFrame:"Web Socket Frame",clearAll:"Clear All",filter:"Filter",selectMessageToBrowseItsContent:"Select message to browse its content.",copyMessageD:"Copy message...",copyMessage:"Copy message",clearAllL:"Clear all",sOpcodeSMask:"{PH1} (Opcode {PH2}, mask)",sOpcodeS:"{PH1} (Opcode {PH2})",continuationFrame:"Continuation Frame",textMessage:"Text Message",binaryMessage:"Binary Message",connectionCloseMessage:"Connection Close Message",pingMessage:"Ping Message",pongMessage:"Pong Message",all:"All",send:"Send",receive:"Receive",na:"N/A",enterRegex:"Enter regex, for example: (web)?socket"},Zt=r.i18n.registerUIStrings("panels/network/ResourceWebSocketFrameView.ts",Qt),er=r.i18n.getLocalizedString.bind(void 0,Zt),tr=r.i18n.getLazilyComputedLocalizedString.bind(void 0,Zt);class rr extends o.Widget.VBox{request;splitWidget;dataGrid;timeComparator;mainToolbar;clearAllButton;filterTypeCombobox;filterType;filterTextInput;filterRegex;frameEmptyWidget;selectedNode;currentSelectedNode;messageFilterSetting=e.Settings.Settings.instance().createSetting("networkWebSocketMessageFilter","");constructor(e){super(),this.element.classList.add("websocket-frame-view"),this.request=e,this.splitWidget=new o.SplitWidget.SplitWidget(!1,!0,"resourceWebSocketFrameSplitViewState"),this.splitWidget.show(this.element);const r=[{id:"data",title:er(Qt.data),sortable:!1,weight:88},{id:"length",title:er(Qt.length),sortable:!1,align:a.DataGrid.Align.Right,weight:5},{id:"time",title:er(Qt.time),sortable:!0,weight:7}];this.dataGrid=new a.SortableDataGrid.SortableDataGrid({displayName:er(Qt.webSocketFrame),columns:r,editCallback:void 0,deleteCallback:void 0,refreshCallback:void 0}),this.dataGrid.setRowContextMenuCallback(function(e,r){const i=r,o=i.binaryView();o?o.addCopyToContextMenu(e,er(Qt.copyMessageD)):e.clipboardSection().appendItem(er(Qt.copyMessage),t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind(t.InspectorFrontendHost.InspectorFrontendHostInstance,i.data.data));e.footerSection().appendItem(er(Qt.clearAllL),this.clearFrames.bind(this))}.bind(this)),this.dataGrid.setStickToBottom(!0),this.dataGrid.setCellClass("websocket-frame-view-td"),this.timeComparator=ar,this.dataGrid.sortNodes(this.timeComparator,!1),this.dataGrid.markColumnAsSortedBy("time",a.DataGrid.Order.Ascending),this.dataGrid.addEventListener(a.DataGrid.Events.SortingChanged,this.sortItems,this),this.dataGrid.setName("ResourceWebSocketFrameView"),this.dataGrid.addEventListener(a.DataGrid.Events.SelectedNode,(e=>{this.onFrameSelected(e)}),this),this.dataGrid.addEventListener(a.DataGrid.Events.DeselectedNode,this.onFrameDeselected,this),this.mainToolbar=new o.Toolbar.Toolbar(""),this.clearAllButton=new o.Toolbar.ToolbarButton(er(Qt.clearAll),"clear"),this.clearAllButton.addEventListener(o.Toolbar.ToolbarButton.Events.Click,this.clearFrames,this),this.mainToolbar.appendToolbarItem(this.clearAllButton),this.filterTypeCombobox=new o.Toolbar.ToolbarComboBox(this.updateFilterSetting.bind(this),er(Qt.filter));for(const e of nr){const t=this.filterTypeCombobox.createOption(e.label(),e.name);this.filterTypeCombobox.addOption(t)}this.mainToolbar.appendToolbarItem(this.filterTypeCombobox),this.filterType=null;const i=er(Qt.enterRegex);this.filterTextInput=new o.Toolbar.ToolbarInput(i,"",.4),this.filterTextInput.addEventListener(o.Toolbar.ToolbarInput.Event.TextChanged,this.updateFilterSetting,this);const n=this.messageFilterSetting.get();n&&this.filterTextInput.setValue(n),this.filterRegex=null,this.mainToolbar.appendToolbarItem(this.filterTextInput);const s=new o.Widget.VBox;s.element.appendChild(this.mainToolbar.element),this.dataGrid.asWidget().show(s.element),s.setMinimumSize(0,72),this.splitWidget.setMainWidget(s),this.frameEmptyWidget=new o.EmptyWidget.EmptyWidget(er(Qt.selectMessageToBrowseItsContent)),this.splitWidget.setSidebarWidget(this.frameEmptyWidget),this.selectedNode=null,n&&this.applyFilter(n)}static opCodeDescription(e,t){const r=or[e]||(()=>"");return er(t?Qt.sOpcodeSMask:Qt.sOpcodeS,{PH1:r(),PH2:e})}wasShown(){this.refresh(),this.registerCSSFiles([Yt]),this.request.addEventListener(s.NetworkRequest.Events.WebsocketFrameAdded,this.frameAdded,this)}willHide(){this.request.removeEventListener(s.NetworkRequest.Events.WebsocketFrameAdded,this.frameAdded,this)}frameAdded(e){const t=e.data;this.frameFilter(t)&&this.dataGrid.insertChild(new sr(this.request.url(),t))}frameFilter(e){return(!this.filterType||e.type===this.filterType)&&(!this.filterRegex||this.filterRegex.test(e.text))}clearFrames(){lr.set(this.request,this.request.frames().length),this.refresh()}updateFilterSetting(){const e=this.filterTextInput.value();this.messageFilterSetting.set(e),this.applyFilter(e)}applyFilter(e){const t=this.filterTypeCombobox.selectedOption().value;this.filterRegex=e?new RegExp(n.StringUtilities.escapeForRegExp(e),"i"):null,this.filterType="all"===t?null:t,this.refresh()}async onFrameSelected(t){this.currentSelectedNode=t.data;const r=this.currentSelectedNode.dataText(),o=this.currentSelectedNode.binaryView();if(o)return void this.splitWidget.setSidebarWidget(o);const n=await i.JSONView.JSONView.createView(r);n?this.splitWidget.setSidebarWidget(n):this.splitWidget.setSidebarWidget(new i.ResourceSourceFrame.ResourceSourceFrame(I.StaticContentProvider.StaticContentProvider.fromString(this.request.url(),e.ResourceType.resourceTypes.WebSocket,r),""))}onFrameDeselected(){this.currentSelectedNode=null,this.splitWidget.setSidebarWidget(this.frameEmptyWidget)}refresh(){this.dataGrid.rootNode().removeChildren();const e=this.request.url();let t=this.request.frames();const r=lr.get(this.request)||0;t=t.slice(r),t=t.filter(this.frameFilter.bind(this)),t.forEach((t=>this.dataGrid.insertChild(new sr(e,t))))}sortItems(){this.dataGrid.sortNodes(this.timeComparator,!this.dataGrid.isSortOrderAscending())}}var ir;!function(e){e[e.ContinuationFrame=0]="ContinuationFrame",e[e.TextFrame=1]="TextFrame",e[e.BinaryFrame=2]="BinaryFrame",e[e.ConnectionCloseFrame=8]="ConnectionCloseFrame",e[e.PingFrame=9]="PingFrame",e[e.PongFrame=10]="PongFrame"}(ir||(ir={}));const or=function(){const e=ir,t=[];return t[e.ContinuationFrame]=tr(Qt.continuationFrame),t[e.TextFrame]=tr(Qt.textMessage),t[e.BinaryFrame]=tr(Qt.binaryMessage),t[e.ConnectionCloseFrame]=tr(Qt.connectionCloseMessage),t[e.PingFrame]=tr(Qt.pingMessage),t[e.PongFrame]=tr(Qt.pongMessage),t}(),nr=[{name:"all",label:tr(Qt.all),title:void 0},{name:"send",label:tr(Qt.send),title:void 0},{name:"receive",label:tr(Qt.receive),title:void 0}];class sr extends a.SortableDataGrid.SortableDataGridNode{url;frame;isTextFrame;dataTextInternal;binaryViewInternal;constructor(e,t){let r=String(t.text.length);const i=new Date(1e3*t.time),a=("0"+i.getHours()).substr(-2)+":"+("0"+i.getMinutes()).substr(-2)+":"+("0"+i.getSeconds()).substr(-2)+"."+("00"+i.getMilliseconds()).substr(-3),l=document.createElement("div");o.UIUtils.createTextChild(l,a),o.Tooltip.Tooltip.install(l,i.toLocaleString());let d=t.text,c=rr.opCodeDescription(t.opCode,t.mask);const h=t.opCode===ir.TextFrame;t.type===s.NetworkRequest.WebSocketFrameType.Error?(c=d,r=er(Qt.na)):h?c=d:t.opCode===ir.BinaryFrame?(r=n.NumberUtilities.bytesToString(n.StringUtilities.base64ToSize(t.text)),c=or[t.opCode]()):d=c,super({data:c,length:r,time:l}),this.url=e,this.frame=t,this.isTextFrame=h,this.dataTextInternal=d,this.binaryViewInternal=null}createCells(e){e.classList.toggle("websocket-frame-view-row-error",this.frame.type===s.NetworkRequest.WebSocketFrameType.Error),e.classList.toggle("websocket-frame-view-row-send",this.frame.type===s.NetworkRequest.WebSocketFrameType.Send),e.classList.toggle("websocket-frame-view-row-receive",this.frame.type===s.NetworkRequest.WebSocketFrameType.Receive),super.createCells(e)}nodeSelfHeight(){return 21}dataText(){return this.dataTextInternal}opCode(){return this.frame.opCode}binaryView(){return this.isTextFrame||this.frame.type===s.NetworkRequest.WebSocketFrameType.Error?null:(this.binaryViewInternal||this.dataTextInternal.length>0&&(this.binaryViewInternal=new V(this.dataTextInternal,n.DevToolsPath.EmptyUrlString,e.ResourceType.resourceTypes.WebSocket)),this.binaryViewInternal)}}function ar(e,t){return e.frame.time-t.frame.time}const lr=new WeakMap;var dr=Object.freeze({__proto__:null,ResourceWebSocketFrameView:rr,get OpCodes(){return ir},opCodeDescriptions:or,_filterTypes:nr,ResourceWebSocketFrameNode:sr,ResourceWebSocketFrameNodeTimeComparator:ar});const cr={headers:"Headers",payload:"Payload",messages:"Messages",websocketMessages:"WebSocket messages",eventstream:"EventStream",preview:"Preview",responsePreview:"Response preview",signedexchangeError:"SignedExchange error",response:"Response",rawResponseData:"Raw response data",initiator:"Initiator",requestInitiatorCallStack:"Request initiator call stack",timing:"Timing",requestAndResponseTimeline:"Request and response timeline",trustTokens:"Private State Tokens",trustTokenOperationDetails:"Private State Token operation details",cookies:"Cookies",requestAndResponseCookies:"Request and response cookies"},hr=r.i18n.registerUIStrings("panels/network/NetworkItemView.ts",cr),ur=r.i18n.getLocalizedString.bind(void 0,hr);class pr extends o.TabbedPane.TabbedPane{requestInternal;resourceViewTabSetting;headersView;headersViewComponent;payloadView;responseView;cookiesView;initialTab;constructor(t,r,i){super(),this.requestInternal=t,this.element.classList.add("network-item-view");const n=c.Runtime.experiments.isEnabled(c.Runtime.ExperimentName.HEADER_OVERRIDES)?g.UIRequestLocation.UIRequestTabs.HeadersComponent:g.UIRequestLocation.UIRequestTabs.Headers;if(this.resourceViewTabSetting=e.Settings.Settings.instance().createSetting("resourceViewTab",n),this.headersView=new Ne(t),this.headersViewComponent=new f.RequestHeadersView.RequestHeadersView(t),c.Runtime.experiments.isEnabled(c.Runtime.ExperimentName.HEADER_OVERRIDES)?this.appendTab(n,ur(cr.headers),b.LegacyWrapper.legacyWrapper(o.Widget.VBox,this.headersViewComponent),ur(cr.headers)):this.appendTab(n,ur(cr.headers),this.headersView,ur(cr.headers)),this.payloadView=null,this.maybeAppendPayloadPanel(),this.addEventListener(o.TabbedPane.Events.TabSelected,this.tabSelected,this),t.resourceType()===e.ResourceType.resourceTypes.WebSocket){const e=new rr(t);this.appendTab(g.UIRequestLocation.UIRequestTabs.WsFrames,ur(cr.messages),e,ur(cr.websocketMessages))}else if(t.mimeType===s.NetworkRequest.MIME_TYPE.EVENTSTREAM)this.appendTab(g.UIRequestLocation.UIRequestTabs.EventSource,ur(cr.eventstream),new Z(t));else{this.responseView=new dt(t);const e=new Ft(t);this.appendTab(g.UIRequestLocation.UIRequestTabs.Preview,ur(cr.preview),e,ur(cr.responsePreview));const r=t.signedExchangeInfo();if(r&&r.errors&&r.errors.length){const e=new k.Icon.Icon;e.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},o.Tooltip.Tooltip.install(e,ur(cr.signedexchangeError)),this.setTabIcon(g.UIRequestLocation.UIRequestTabs.Preview,e)}this.appendTab(g.UIRequestLocation.UIRequestTabs.Response,ur(cr.response),this.responseView,ur(cr.rawResponseData))}this.appendTab(g.UIRequestLocation.UIRequestTabs.Initiator,ur(cr.initiator),new tt(t),ur(cr.requestInitiatorCallStack)),this.appendTab(g.UIRequestLocation.UIRequestTabs.Timing,ur(cr.timing),new jt(t,r),ur(cr.requestAndResponseTimeline)),t.trustTokenParams()&&this.appendTab(g.UIRequestLocation.UIRequestTabs.TrustTokens,ur(cr.trustTokens),b.LegacyWrapper.legacyWrapper(o.Widget.VBox,new f.RequestTrustTokensView.RequestTrustTokensView(t)),ur(cr.trustTokenOperationDetails)),this.cookiesView=null,this.initialTab=i||this.resourceViewTabSetting.get(),this.setAutoSelectFirstItemOnShow(!1)}wasShown(){super.wasShown(),this.requestInternal.addEventListener(s.NetworkRequest.Events.RequestHeadersChanged,this.requestHeadersChanged,this),this.requestInternal.addEventListener(s.NetworkRequest.Events.ResponseHeadersChanged,this.maybeAppendCookiesPanel,this),this.requestInternal.addEventListener(s.NetworkRequest.Events.TrustTokenResultAdded,this.maybeShowErrorIconInTrustTokenTabHeader,this),this.maybeAppendCookiesPanel(),this.maybeShowErrorIconInTrustTokenTabHeader(),this.initialTab&&(this.selectTabInternal(this.initialTab),this.initialTab=void 0)}willHide(){this.requestInternal.removeEventListener(s.NetworkRequest.Events.RequestHeadersChanged,this.requestHeadersChanged,this),this.requestInternal.removeEventListener(s.NetworkRequest.Events.ResponseHeadersChanged,this.maybeAppendCookiesPanel,this),this.requestInternal.removeEventListener(s.NetworkRequest.Events.TrustTokenResultAdded,this.maybeShowErrorIconInTrustTokenTabHeader,this)}async requestHeadersChanged(){this.maybeAppendCookiesPanel(),this.maybeAppendPayloadPanel()}maybeAppendCookiesPanel(){const e=this.requestInternal.hasRequestCookies()||this.requestInternal.responseCookies.length>0;console.assert(e||!this.cookiesView,"Cookies were introduced in headers and then removed!"),e&&!this.cookiesView&&(this.cookiesView=new Re(this.requestInternal),this.appendTab(g.UIRequestLocation.UIRequestTabs.Cookies,ur(cr.cookies),this.cookiesView,ur(cr.requestAndResponseCookies)))}async maybeAppendPayloadPanel(){this.hasTab("payload")||(this.requestInternal.queryParameters||await this.requestInternal.requestFormData())&&(this.payloadView=new je(this.requestInternal),this.appendTab(g.UIRequestLocation.UIRequestTabs.Payload,ur(cr.payload),this.payloadView,ur(cr.payload),void 0,void 0,void 0,1))}maybeShowErrorIconInTrustTokenTabHeader(){const e=this.requestInternal.trustTokenOperationDoneEvent();if(e&&!f.RequestTrustTokensView.statusConsideredSuccess(e.status)){const e=new k.Icon.Icon;e.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},this.setTabIcon(g.UIRequestLocation.UIRequestTabs.TrustTokens,e)}}selectTabInternal(e){this.selectTab(e)||window.setTimeout((()=>{this.selectTab(e)||this.selectTab("headers")}),0)}tabSelected(e){e.data.isUserGesture&&this.resourceViewTabSetting.set(e.data.tabId)}request(){return this.requestInternal}async revealResponseBody(e){this.selectTabInternal(g.UIRequestLocation.UIRequestTabs.Response),this.responseView&&"number"==typeof e&&await this.responseView.revealLine(e)}revealHeader(e,t){c.Runtime.experiments.isEnabled(c.Runtime.ExperimentName.HEADER_OVERRIDES)?(this.selectTabInternal(g.UIRequestLocation.UIRequestTabs.HeadersComponent),this.headersViewComponent.revealHeader(e,t)):(this.selectTabInternal(g.UIRequestLocation.UIRequestTabs.Headers),this.headersView.revealHeader(e,t))}getHeadersView(){return this.headersView}getHeadersViewComponent(){return this.headersViewComponent}}var gr=Object.freeze({__proto__:null,NetworkItemView:pr});const mr=new CSSStyleSheet;mr.replaceSync('.network-log-grid.data-grid{border:none!important;flex:auto}.network-log-grid.data-grid.no-selection:focus-visible{border:none!important}#network-container{border:1px solid var(--color-details-hairline);overflow:hidden}#network-container.grid-focused.no-node-selected:focus-within{border:1px solid var(--legacy-accent-color)}.network-summary-bar{flex:0 0 27px;line-height:27px;padding-left:5px;background-color:var(--color-background-elevation-1);border-top:1px solid var(--color-details-hairline);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;user-select:text}.panel.network .toolbar.network-summary-bar{border-bottom:0}.network-summary-bar span[is="dt-icon-label"]{margin-right:6px}.network-summary-bar > *{flex:none}.network-log-grid.data-grid tbody{background:transparent}.network-log-grid.data-grid td{height:41px;border-left:1px solid var(--color-details-hairline);vertical-align:middle}.network-log-grid.data-grid .corner{display:none}.network-log-grid.data-grid.small td{height:21px}.network-log-grid.data-grid th{border-bottom:none}.network-waterfall-header,\n.network-log-grid.data-grid thead th{border-bottom:1px solid var(--color-details-hairline);border-left:1px solid var(--color-details-hairline)}.network-waterfall-header,\n.network-log-grid.data-grid thead{height:31px;background-color:var(--color-background-elevation-1)}.network-waterfall-header.small,\n.network-log-grid.data-grid.small thead{height:27px}.network-log-grid.data-grid select{appearance:none;border:none;width:100%;color:inherit}.network-log-grid.data-grid .waterfall-column{padding:1px 0}.network-log-grid.data-grid .waterfall-column .sort-order-icon-container{right:15px;pointer-events:none}.network-log-grid.data-grid th.sortable:active{background-image:none!important}.network-cell-subtitle{font-weight:normal;color:var(--color-text-secondary)}.network-badge{margin-right:4px}.status-column .devtools-link{color:inherit}.initiator-column .devtools-link{color:inherit}.network-error-row,\n.network-error-row .network-cell-subtitle{color:var(--color-red)!important}.network-log-grid.data-grid tr.selected.network-error-row,\n.network-log-grid.data-grid tr.selected.network-error-row .network-cell-subtitle,\n.network-log-grid.data-grid tr.selected.network-error-row .network-dim-cell,\n.network-log-grid.data-grid:focus-within tr.selected.network-error-row .devtools-link,\n.network-log-grid.data-grid:focus-within tr.selected.network-error-row,\n.network-log-grid.data-grid:focus-within tr.selected.network-error-row .network-cell-subtitle,\n.network-log-grid.data-grid:focus-within tr.selected.network-error-row .network-dim-cell{color:var(--color-accent-red)}.network-log-grid.data-grid tr.selected,\n.network-log-grid.data-grid tr.selected .network-cell-subtitle,\n.network-log-grid.data-grid tr.selected .network-dim-cell{color:inherit}.network-log-grid.data-grid:focus tr.selected,\n.network-log-grid.data-grid:focus tr.selected .network-cell-subtitle,\n.network-log-grid.data-grid:focus tr.selected .network-dim-cell{color:var(--legacy-selection-fg-color)}.network-log-grid.data-grid:focus-within tr.selected [is="ui-icon"]{background-color:var(--icon-force-white)}.network-header-subtitle{color:var(--color-text-secondary)}.network-log-grid.data-grid.small .network-cell-subtitle,\n.network-log-grid.data-grid.small .network-header-subtitle{display:none}.network-log-grid.data-grid.small tr.selected .network-cell-subtitle-show-inline-when-selected{display:inline;margin-left:4px}.network-log-grid tr.highlighted-row{--override-highlight-fade-from:rgb(255 255 120/100%);--override-highlight-fade-to:rgb(255 255 120/0%);animation:network-row-highlight-fadeout 2s 0s}@keyframes network-row-highlight-fadeout{from{background-color:var(--override-highlight-fade-from)}to{background-color:var(--override-highlight-fade-to)}}.network-log-grid.data-grid .icon.image{position:relative}.network-log-grid.data-grid .icon{float:left;width:32px;height:32px;margin-top:1px;margin-right:3px}.network-log-grid.data-grid:focus-within .data-grid-data-grid-node.selected div.icon:not(.image){filter:brightness(0) invert(1)}.network-log-grid.data-grid:focus-within .data-grid-data-grid-node.selected [is="ui-icon"].icon-mask{--network-grid-selected-color:#dadce0;--override-icon-mask-background-color:var(--network-grid-selected-color)}.data-grid-data-grid-node [is="ui-icon"].arrow-up-down-circle{transform:scale(0.8)}.network-log-grid.data-grid .network-error-row.data-grid-data-grid-node img.icon,\n.network-log-grid.data-grid .network-error-row.data-grid-data-grid-node.selected img.icon{filter:brightness(0) saturate(100%) invert(35%) sepia(76%) saturate(1413%) hue-rotate(338deg) brightness(92%) contrast(103%)}.network-log-grid.data-grid.small .icon{margin-top:2px;width:16px;height:16px}.image-network-icon-preview{background:var(--color-image-preview-background);border:1px solid var(--color-details-hairline);bottom:0;left:0;margin:auto;overflow:hidden;right:0;top:0}.network-log-grid.data-grid .image-network-icon-preview{position:absolute;max-width:18px;max-height:21px;min-width:1px;min-height:1px}.network-log-grid.data-grid.small .image-network-icon-preview{left:2px;right:2px;max-width:10px;max-height:12px}.network-log-grid.data-grid .trailing-link-icon{padding-left:0.5ex}.network-dim-cell{color:var(--color-text-secondary)}.network-frame-divider{--override-frame-divider:#fccc49;width:2px;background-color:var(--override-frame-divider);z-index:10;visibility:hidden}.-theme-with-dark-background .network-frame-divider,\n:host-context(.-theme-with-dark-background) .network-frame-divider{--override-frame-divider:rgb(182 134 3)}#network-container:not(.brief-mode) .data-container{overflow:hidden}.network-log-grid.data-grid .resources-dividers{z-index:0}.network-log-grid.data-grid .resources-dividers-label-bar{background-color:transparent;border:none;height:30px;pointer-events:none}.network-log-grid.data-grid span.separator-in-cell{user-select:none;min-width:1ex;display:inline-block}.network-status-pane{color:var(--color-text-secondary);background-color:var(--color-background);z-index:500;display:flex;justify-content:center;align-items:center;text-align:center;padding:0 20px;overflow:auto}.network-status-pane > .recording-hint{font-size:14px;text-align:center;line-height:28px}.network-waterfall-header{position:absolute;border-left:0;width:100%;display:table;z-index:200}.network-waterfall-header:hover{background-color:var(--color-background-highlight)}.network-waterfall-header div{display:table-cell;line-height:14px;margin:auto 0;vertical-align:middle;text-align:left;font-weight:normal;padding:0 4px}.network-waterfall-header .sort-order-icon-container{position:absolute;top:1px;right:0;bottom:1px;display:flex;align-items:center}.network-waterfall-header .sort-order-icon{align-items:center;margin-right:4px;margin-bottom:-2px}.network-frame-group-icon{display:inline-block;margin:-7px 1px}.network-frame-group-badge{margin-right:4px}.network-override-marker{background:rgb(175 75 246);border-radius:50%;width:8px;height:8px;display:inline-block;margin-right:3px}@media (forced-colors: active){.network-status-pane > .recording-hint{color:canvastext}.initiator-column .devtools-link{color:linktext}.network-log-grid.data-grid tbody tr.revealed.selected,\n  .network-log-grid.data-grid:focus-within tbody tr.revealed.selected,\n  .network-log-grid.data-grid:focus-within tr.selected .network-dim-cell,\n  .network-log-grid.data-grid tr.selected .network-dim-cell,\n  .network-log-grid.data-grid:focus-within tr.selected .initiator-column .devtools-link,\n  .network-log-grid.data-grid tr.selected .initiator-column .devtools-link,\n  .network-waterfall-header:hover *{color:HighlightText}.network-log-grid{--network-grid-default-color:canvas;--network-grid-stripe-color:canvas;--network-grid-hovered-color:Highlight;--network-grid-selected-color:ButtonText;--network-grid-focus-selected-color:Highlight}#network-container.no-node-selected:focus-within,\n  .network-status-pane{forced-color-adjust:none;border-color:Highlight;background-color:canvas!important}.network-waterfall-header:hover{forced-color-adjust:none;background-color:Highlight}.network-waterfall-header.small,\n  .network-log-grid.data-grid.small thead .network-waterfall-header,\n  .network-log-grid.data-grid thead{background-color:canvas}.network-waterfall-header:hover .sort-order-icon-container [is="ui-icon"].icon-mask{background-color:HighlightText}}\n/*# sourceURL=networkLogView.css */\n');class wr{parentView;activeGroups;constructor(e){this.parentView=e,this.activeGroups=new Map}groupNodeForRequest(e){const t=s.ResourceTreeModel.ResourceTreeModel.frameForRequest(e);if(!t||t.isOutermostFrame())return null;let r=this.activeGroups.get(t);return r||(r=new vr(this.parentView,t),this.activeGroups.set(t,r),r)}reset(){this.activeGroups.clear()}}class vr extends fe{frame;constructor(e,t){super(e),this.frame=t}displayName(){return new e.ParsedURL.ParsedURL(this.frame.url).domain()||this.frame.name||"<iframe>"}renderCell(e,t){super.renderCell(e,t);if(0===this.dataGrid.indexOfVisibleColumn(t)){const r=this.displayName();e.appendChild(o.Icon.Icon.create("frame","network-frame-group-icon")),o.UIUtils.createTextChild(e,r),o.Tooltip.Tooltip.install(e,r),this.setCellAccessibleName(e.textContent||"",e,t)}}}var kr=Object.freeze({__proto__:null,NetworkFrameGrouper:wr,FrameGroupNode:vr});const br=new CSSStyleSheet;br.replaceSync(".custom-headers-list{height:272px;width:250px}.custom-headers-wrapper{margin:10px}.header{padding:0 0 6px;font-size:18px;font-weight:normal;flex:none}.custom-headers-header{padding:2px}.custom-headers-list-item{padding-left:5px}.editor-container{padding:5px 0 0 5px}.add-button{width:150px;margin:auto;margin-top:5px}\n/*# sourceURL=networkManageCustomHeadersView.css */\n");const fr={manageHeaderColumns:"Manage Header Columns",noCustomHeaders:"No custom headers",addCustomHeader:"Add custom header…",headerName:"Header Name"},Cr=r.i18n.registerUIStrings("panels/network/NetworkManageCustomHeadersView.ts",fr),Sr=r.i18n.getLocalizedString.bind(void 0,Cr);class Tr extends o.Widget.VBox{list;columnConfigs;addHeaderColumnCallback;changeHeaderColumnCallback;removeHeaderColumnCallback;editor;constructor(e,t,r,i){super(!0),this.contentElement.classList.add("custom-headers-wrapper"),this.contentElement.createChild("div","header").textContent=Sr(fr.manageHeaderColumns),this.list=new o.ListWidget.ListWidget(this),this.list.element.classList.add("custom-headers-list");const n=document.createElement("div");n.classList.add("custom-headers-list-list-empty"),n.textContent=Sr(fr.noCustomHeaders),this.list.setEmptyPlaceholder(n),this.list.show(this.contentElement),this.contentElement.appendChild(o.UIUtils.createTextButton(Sr(fr.addCustomHeader),this.addButtonClicked.bind(this),"add-button")),this.columnConfigs=new Map,e.forEach((e=>this.columnConfigs.set(e.title.toLowerCase(),e))),this.addHeaderColumnCallback=t,this.changeHeaderColumnCallback=r,this.removeHeaderColumnCallback=i,this.contentElement.tabIndex=0}wasShown(){this.headersUpdated(),this.list.registerCSSFiles([br]),this.registerCSSFiles([br])}headersUpdated(){this.list.clear(),this.columnConfigs.forEach((e=>this.list.appendItem({header:e.title},e.editable)))}addButtonClicked(){this.list.addNewItem(this.columnConfigs.size,{header:""})}renderItem(e,t){const r=document.createElement("div");r.classList.add("custom-headers-list-item");const i=r.createChild("div","custom-header-name");return i.textContent=e.header,o.Tooltip.Tooltip.install(i,e.header),r}removeItemRequested(e,t){this.removeHeaderColumnCallback(e.header),this.columnConfigs.delete(e.header.toLowerCase()),this.headersUpdated()}commitEdit(e,t,r){const i=t.control("header").value.trim();let o;o=r?this.addHeaderColumnCallback(i):this.changeHeaderColumnCallback(e.header,i),o&&!r&&this.columnConfigs.delete(e.header.toLowerCase()),o&&this.columnConfigs.set(i.toLowerCase(),{title:i,editable:!0}),this.headersUpdated()}beginEdit(e){const t=this.createEditor();return t.control("header").value=e.header,t}createEditor(){if(this.editor)return this.editor;const e=new o.ListWidget.Editor;this.editor=e;const t=e.contentElement();t.createChild("div","custom-headers-edit-row").createChild("div","custom-headers-header").textContent=Sr(fr.headerName);return t.createChild("div","custom-headers-edit-row").createChild("div","custom-headers-header").appendChild(e.createInput("header","text","x-custom-header",function(t,r,i){let o=!0;const n=e.control("header").value.trim().toLowerCase();this.columnConfigs.has(n)&&t.header!==n&&(o=!1);return{valid:o,errorMessage:void 0}}.bind(this))),e}}var yr=Object.freeze({__proto__:null,NetworkManageCustomHeadersView:Tr});const xr=new CSSStyleSheet;xr.replaceSync(".network-waterfall-v-scroll{position:absolute;top:0;right:0;bottom:0;overflow-x:hidden;margin-top:31px;z-index:200}.-theme-with-dark-background .network-waterfall-v-scroll{background:rgb(0 0 0/1%)}.network-waterfall-v-scroll.small{margin-top:27px}.network-waterfall-v-scroll-content{width:15px;pointer-events:none}\n/*# sourceURL=networkWaterfallColumn.css */\n");const Rr=P.RenderCoordinator.RenderCoordinator.instance();class Ir extends m.TimelineOverviewPane.TimelineOverviewBase{selectedFilmStripTime;numBands;highlightedRequest;loadEvents;domContentLoadedEvents;nextBand;bandMap;requestsList;requestsSet;span;filmStripModel;lastBoundary;constructor(){super(),this.selectedFilmStripTime=-1,this.element.classList.add("network-overview"),this.numBands=1,this.highlightedRequest=null,s.TargetManager.TargetManager.instance().addModelListener(s.ResourceTreeModel.ResourceTreeModel,s.ResourceTreeModel.Events.Load,this.loadEventFired,this,{scoped:!0}),s.TargetManager.TargetManager.instance().addModelListener(s.ResourceTreeModel.ResourceTreeModel,s.ResourceTreeModel.Events.DOMContentLoaded,this.domContentLoadedEventFired,this,{scoped:!0}),this.reset()}setHighlightedRequest(e){this.highlightedRequest=e,this.scheduleUpdate()}setFilmStripModel(e){this.filmStripModel=e,this.scheduleUpdate()}selectFilmStripFrame(e){this.selectedFilmStripTime=e,this.scheduleUpdate()}clearFilmStripFrame(){this.selectedFilmStripTime=-1,this.scheduleUpdate()}loadEventFired(e){const t=e.data.loadTime;t&&this.loadEvents.push(1e3*t),this.scheduleUpdate()}domContentLoadedEventFired(e){const{data:t}=e;t&&this.domContentLoadedEvents.push(1e3*t),this.scheduleUpdate()}bandId(e){if(!e||"0"===e)return-1;if(this.bandMap.has(e))return this.bandMap.get(e);const t=this.nextBand++;return this.bandMap.set(e,t),t}updateRequest(e){this.requestsSet.has(e)||(this.requestsSet.add(e),this.requestsList.push(e)),this.scheduleUpdate()}wasShown(){this.onResize()}calculator(){return super.calculator()}onResize(){const e=this.element.offsetWidth,t=this.element.offsetHeight;this.calculator().setDisplayWidth(e),this.resetCanvas();const r=(t-Fr-1)/Lr-1|0;this.numBands=r>0?r:1,this.scheduleUpdate()}reset(){this.filmStripModel=null,this.span=1,this.lastBoundary=null,this.nextBand=0,this.bandMap=new Map,this.requestsList=[],this.requestsSet=new Set,this.loadEvents=[],this.domContentLoadedEvents=[],this.resetCanvas()}scheduleUpdate(){this.isShowing()&&Rr.write("NetworkOverview.render",this.update.bind(this))}update(){const e=this.calculator(),t=new Ut(e.minimumBoundary(),e.maximumBoundary());if(!this.lastBoundary||!t.equals(this.lastBoundary)){const t=e.boundarySpan();for(;this.span<t;)this.span*=1.25;e.setBounds(e.minimumBoundary(),e.minimumBoundary()+this.span),this.lastBoundary=new Ut(e.minimumBoundary(),e.maximumBoundary())}const r=this.context(),i=new Map,o=Fr;function n(t){const n=i.get(t);if(!n)return;const s=n.length;r.beginPath(),r.strokeStyle=E.ThemeSupport.instance().getComputedValue("--color-background-opacity-80"),r.lineWidth=Hr,r.fillStyle=E.ThemeSupport.instance().getComputedValue(qr[t]);for(let t=0;t<s;){const i=n[t++]*Lr+o,s=n[t++];let a=n[t++];a===Number.MAX_VALUE&&(a=e.maximumBoundary());const l=e.computePosition(s),d=e.computePosition(a)+1;r.fillRect(l,i,d-l,Lr),r.strokeRect(l,i,d-l,Lr)}}function s(e,t,r,o){let n=i.get(e);n||(n=[],i.set(e,n)),n.push(t,r,o)}const a=this.requestsList,l=a.length;for(let e=0;e<l;++e){const t=a[e],r=this.bandId(t.connectionId),i=-1===r?0:r%this.numBands+1,o=jt.calculateRequestTimeRanges(t,this.calculator().minimumBoundary());for(let e=0;e<o.length;++e){const t=o[e].name;-1===r&&t!==Kt.Total||s(t,i,1e3*o[e].start,1e3*o[e].end)}}if(r.clearRect(0,0,this.width(),this.height()),r.save(),r.scale(window.devicePixelRatio,window.devicePixelRatio),r.lineWidth=2,n(Kt.Total),n(Kt.Blocking),n(Kt.Connecting),n(Kt.ServiceWorker),n(Kt.ServiceWorkerPreparation),n(Kt.ServiceWorkerRespondWith),n(Kt.Push),n(Kt.Proxy),n(Kt.DNS),n(Kt.SSL),n(Kt.Sending),n(Kt.Waiting),n(Kt.Receiving),this.highlightedRequest){const t=5,i=2,n=this.highlightedRequest,s=this.bandId(n.connectionId),a=(-1===s?0:s%this.numBands+1)*Lr+o,l=jt.calculateRequestTimeRanges(n,this.calculator().minimumBoundary());r.fillStyle=E.ThemeSupport.instance().getComputedValue("--legacy-selection-bg-color");const d=1e3*l[0].start,c=1e3*l[0].end;r.fillRect(e.computePosition(d)-i,a-t/2-i,e.computePosition(c)-e.computePosition(d)+1+2*i,t*i);for(let i=0;i<l.length;++i){const o=l[i].name;if(-1!==s||o===Kt.Total){r.beginPath(),r.strokeStyle=E.ThemeSupport.instance().getComputedValue(qr[o]),r.lineWidth=t;const n=1e3*l[i].start,s=1e3*l[i].end;r.moveTo(e.computePosition(n)-0,a),r.lineTo(e.computePosition(s)+1,a),r.stroke()}}}const d=this.element.offsetHeight;r.lineWidth=1,r.beginPath(),r.strokeStyle=E.ThemeSupport.instance().getComputedValue(Qr.getDCLEventColor());for(let t=this.domContentLoadedEvents.length-1;t>=0;--t){const i=Math.round(e.computePosition(this.domContentLoadedEvents[t]))+.5;r.moveTo(i,0),r.lineTo(i,d)}r.stroke(),r.beginPath(),r.strokeStyle=E.ThemeSupport.instance().getComputedValue(Qr.getLoadEventColor());for(let t=this.loadEvents.length-1;t>=0;--t){const i=Math.round(e.computePosition(this.loadEvents[t]))+.5;r.moveTo(i,0),r.lineTo(i,d)}if(r.stroke(),-1!==this.selectedFilmStripTime){r.lineWidth=2,r.beginPath(),r.strokeStyle=E.ThemeSupport.instance().getComputedValue("--network-frame-divider-color");const t=Math.round(e.computePosition(this.selectedFilmStripTime));r.moveTo(t,0),r.lineTo(t,d),r.stroke()}r.restore()}}const qr={[Kt.Total]:"--override-network-overview-total",[Kt.Blocking]:"--override-network-overview-blocking",[Kt.Connecting]:"--override-network-overview-connecting",[Kt.ServiceWorker]:"--override-network-overview-service-worker",[Kt.ServiceWorkerPreparation]:"--override-network-overview-service-worker",[Kt.ServiceWorkerRespondWith]:"--override-network-overview-service-worker-respond-with",[Kt.Push]:"--override-network-overview-push",[Kt.Proxy]:"--override-network-overview-proxy",[Kt.DNS]:"--override-network-overview-dns",[Kt.SSL]:"--override-network-overview-ssl",[Kt.Sending]:"--override-network-overview-sending",[Kt.Waiting]:"--override-network-overview-waiting",[Kt.Receiving]:"--override-network-overview-receiving",[Kt.Queueing]:"--override-network-overview-queueing"},Lr=3,Fr=5,Hr=1;var Pr=Object.freeze({__proto__:null,NetworkOverview:Ir,RequestTimeRangeNameToColor:qr,_bandHeight:Lr,_padding:Fr});const Er=P.RenderCoordinator.RenderCoordinator.instance();class Mr extends o.Widget.VBox{canvas;canvasPosition;leftPadding;fontSize;rightPadding;scrollTop;headerHeight;calculator;rawRowHeight;rowHeight;offsetWidth;offsetHeight;startTime;endTime;popoverHelper;nodes;hoveredNode;eventDividers;styleForTimeRangeName;styleForWaitingResourceType;styleForDownloadingResourceType;wiskerStyle;hoverDetailsStyle;pathForStyle;textLayers;constructor(e){super(!1),this.canvas=this.contentElement.createChild("canvas"),this.canvas.tabIndex=-1,this.setDefaultFocusedElement(this.canvas),this.canvasPosition=this.canvas.getBoundingClientRect(),this.leftPadding=5,this.fontSize=10,this.rightPadding=0,this.scrollTop=0,this.headerHeight=0,this.calculator=e,this.rawRowHeight=0,this.rowHeight=0,this.offsetWidth=0,this.offsetHeight=0,this.startTime=this.calculator.minimumBoundary(),this.endTime=this.calculator.maximumBoundary(),this.popoverHelper=new o.PopoverHelper.PopoverHelper(this.element,this.getPopoverRequest.bind(this)),this.popoverHelper.setHasPadding(!0),this.popoverHelper.setTimeout(300,300),this.nodes=[],this.hoveredNode=null,this.eventDividers=new Map,this.element.addEventListener("mousemove",this.onMouseMove.bind(this),!0),this.element.addEventListener("mouseleave",(e=>this.setHoveredNode(null,!1)),!0),this.element.addEventListener("click",this.onClick.bind(this),!0),this.styleForTimeRangeName=Mr.buildRequestTimeRangeStyle();const t=Mr.buildResourceTypeStyle();this.styleForWaitingResourceType=t[0],this.styleForDownloadingResourceType=t[1];const r=E.ThemeSupport.instance().getComputedValue("--color-text-disabled");this.wiskerStyle={borderColor:r,lineWidth:1,fillStyle:void 0},this.hoverDetailsStyle={fillStyle:r,lineWidth:1,borderColor:r},this.pathForStyle=new Map,this.textLayers=[]}static buildRequestTimeRangeStyle(){const e=Kt,t=new Map;return t.set(e.Connecting,{fillStyle:qr[e.Connecting]}),t.set(e.SSL,{fillStyle:qr[e.SSL]}),t.set(e.DNS,{fillStyle:qr[e.DNS]}),t.set(e.Proxy,{fillStyle:qr[e.Proxy]}),t.set(e.Blocking,{fillStyle:qr[e.Blocking]}),t.set(e.Push,{fillStyle:qr[e.Push]}),t.set(e.Queueing,{fillStyle:qr[e.Queueing],lineWidth:2,borderColor:"lightgrey"}),t.set(e.Receiving,{fillStyle:qr[e.Receiving],lineWidth:2,borderColor:"#03A9F4"}),t.set(e.Waiting,{fillStyle:qr[e.Waiting]}),t.set(e.ReceivingPush,{fillStyle:qr[e.ReceivingPush]}),t.set(e.ServiceWorker,{fillStyle:qr[e.ServiceWorker]}),t.set(e.ServiceWorkerPreparation,{fillStyle:qr[e.ServiceWorkerPreparation]}),t.set(e.ServiceWorkerRespondWith,{fillStyle:qr[e.ServiceWorkerRespondWith]}),t}static buildResourceTypeStyle(){const t=new Map([["document","hsl(215, 100%, 80%)"],["font","hsl(8, 100%, 80%)"],["media","hsl(90, 50%, 80%)"],["image","hsl(90, 50%, 80%)"],["script","hsl(31, 100%, 80%)"],["stylesheet","hsl(272, 64%, 80%)"],["texttrack","hsl(8, 100%, 80%)"],["websocket","hsl(0, 0%, 95%)"],["xhr","hsl(53, 100%, 80%)"],["fetch","hsl(53, 100%, 80%)"],["other","hsl(0, 0%, 95%)"]]),r=new Map,i=new Map;for(const s of Object.values(e.ResourceType.resourceTypes)){let e=t.get(s.name());e||(e=t.get("other"));const a=o(e);r.set(s,{fillStyle:n(e),lineWidth:1,borderColor:a}),i.set(s,{fillStyle:e,lineWidth:1,borderColor:a})}return[r,i];function o(t){const r=e.Color.parse(t)?.as("hsl");if(!r)return"";let{s:i,l:o}=r;return i/=2,o-=Math.min(o,.2),new e.Color.HSL(r.h,i,o,r.alpha).asString()}function n(t){const r=e.Color.parse(t)?.as("hsl");if(!r)return"";let{l:i}=r;return i*=1.1,new e.Color.HSL(r.h,r.s,i,r.alpha).asString()}}resetPaths(){this.pathForStyle.clear(),this.pathForStyle.set(this.wiskerStyle,new Path2D),this.styleForTimeRangeName.forEach((e=>this.pathForStyle.set(e,new Path2D))),this.styleForWaitingResourceType.forEach((e=>this.pathForStyle.set(e,new Path2D))),this.styleForDownloadingResourceType.forEach((e=>this.pathForStyle.set(e,new Path2D))),this.pathForStyle.set(this.hoverDetailsStyle,new Path2D)}willHide(){this.popoverHelper.hidePopover()}wasShown(){this.update(),this.registerCSSFiles([xr])}onMouseMove(e){this.setHoveredNode(this.getNodeFromPoint(e.offsetX,e.offsetY),e.shiftKey)}onClick(e){this.setSelectedNode(this.getNodeFromPoint(e.offsetX,e.offsetY))&&e.consume(!0)}getPopoverRequest(t){if(!this.hoveredNode)return null;const r=this.hoveredNode.request();if(!r)return null;let i,o,n;if(!e.Settings.Settings.instance().moduleSetting("networkColorCodeResourceTypes").get()&&!this.calculator.startAtZero?(i=jt.calculateRequestTimeRanges(r,0).find((e=>e.name===Kt.Total)),o=this.timeToPosition(i.start),n=this.timeToPosition(i.end)):(i=this.getSimplifiedBarRange(r,0),o=i.start,n=i.end),n-o<50){const e=(n-o)/2;o=o+e-25,n=n-e+25}if(t.clientX<this.canvasPosition.left+o||t.clientX>this.canvasPosition.left+n)return null;const s=this.nodes.findIndex((e=>e.hovered())),a=this.getBarHeight(i.name),l=this.headerHeight+(this.rowHeight*s-this.scrollTop)+(this.rowHeight-a)/2;if(t.clientY<this.canvasPosition.top+l||t.clientY>this.canvasPosition.top+l+a)return null;const d=this.element.boxInWindow();return d.x+=o,d.y+=l,d.width=n-o,d.height=a,{box:d,show:e=>{const t=jt.createTimingTable(r,this.calculator);return e.registerCSSFiles([Dt]),e.contentElement.appendChild(t),Promise.resolve(!0)},hide:void 0}}setHoveredNode(e,t){this.hoveredNode&&this.hoveredNode.setHovered(!1,!1),this.hoveredNode=e,this.hoveredNode&&this.hoveredNode.setHovered(!0,t)}setSelectedNode(e){return!(!e||!e.dataGrid)&&(e.select(),e.dataGrid.element.focus(),!0)}setRowHeight(e){this.rawRowHeight=e,this.updateRowHeight()}updateRowHeight(){this.rowHeight=Math.round(this.rawRowHeight*window.devicePixelRatio)/window.devicePixelRatio}setHeaderHeight(e){this.headerHeight=e}setRightPadding(e){this.rightPadding=e,this.calculateCanvasSize()}setCalculator(e){this.calculator=e}getNodeFromPoint(e,t){return t<=this.headerHeight?null:this.nodes[Math.floor((this.scrollTop+t-this.headerHeight)/this.rowHeight)]}scheduleDraw(){Er.write("NetworkWaterfallColumn.render",(()=>this.update()))}update(e,t,r){void 0!==e&&this.scrollTop!==e&&(this.popoverHelper.hidePopover(),this.scrollTop=e),r&&(this.nodes=r,this.calculateCanvasSize()),void 0!==t&&(this.eventDividers=t),this.startTime=this.calculator.minimumBoundary(),this.endTime=this.calculator.maximumBoundary(),this.resetCanvas(),this.resetPaths(),this.textLayers=[],this.draw()}resetCanvas(){const e=window.devicePixelRatio;this.canvas.width=this.offsetWidth*e,this.canvas.height=this.offsetHeight*e,this.canvas.style.width=this.offsetWidth+"px",this.canvas.style.height=this.offsetHeight+"px"}onResize(){super.onResize(),this.updateRowHeight(),this.calculateCanvasSize(),this.scheduleDraw()}calculateCanvasSize(){this.offsetWidth=this.contentElement.offsetWidth-this.rightPadding,this.offsetHeight=this.contentElement.offsetHeight,this.calculator.setDisplayWidth(this.offsetWidth),this.canvasPosition=this.canvas.getBoundingClientRect()}timeToPosition(e){const t=(this.offsetWidth-this.leftPadding)/(this.endTime-this.startTime);return Math.floor(this.leftPadding+(e-this.startTime)*t)}didDrawForTest(){}draw(){const t=!e.Settings.Settings.instance().moduleSetting("networkColorCodeResourceTypes").get()&&!this.calculator.startAtZero,r=this.nodes,i=this.canvas.getContext("2d");if(!i)return;i.save(),i.scale(window.devicePixelRatio,window.devicePixelRatio),i.translate(0,this.headerHeight),i.rect(0,0,this.offsetWidth,this.offsetHeight),i.clip();const o=Math.floor(this.scrollTop/this.rowHeight),n=Math.min(r.length,o+Math.ceil(this.offsetHeight/this.rowHeight));for(let e=o;e<n;e++){const o=this.rowHeight*e,n=r[e];this.decorateRow(i,n,o-this.scrollTop);let s=[];n.hasChildren()&&!n.expanded&&(s=n.flatChildren()),s.push(n);for(const e of s)t?this.buildTimingBarLayers(e,o-this.scrollTop):this.buildSimplifiedBarLayers(i,e,o-this.scrollTop)}this.drawLayers(i,t),i.save(),i.fillStyle=E.ThemeSupport.instance().getComputedValue("--color-text-disabled");for(const e of this.textLayers)i.fillText(e.text,e.x,e.y);i.restore(),this.drawEventDividers(i),i.restore();const s=m.TimelineGrid.TimelineGrid.calculateGridOffsets(this.calculator);m.TimelineGrid.TimelineGrid.drawCanvasGrid(i,s),m.TimelineGrid.TimelineGrid.drawCanvasHeaders(i,s,(e=>this.calculator.formatValue(e,s.precision)),this.fontSize,this.headerHeight,75),i.save(),i.scale(window.devicePixelRatio,window.devicePixelRatio),i.clearRect(this.offsetWidth-18,0,18,this.headerHeight),i.restore(),this.didDrawForTest()}drawLayers(e,t){for(const r of this.pathForStyle){const i=r[0],o=r[1];e.save(),e.beginPath(),i.lineWidth&&(e.lineWidth=i.lineWidth,i.borderColor&&(e.strokeStyle=i.borderColor),e.stroke(o)),i.fillStyle&&(e.fillStyle=t?E.ThemeSupport.instance().getComputedValue(i.fillStyle):i.fillStyle,e.fill(o)),e.restore()}}drawEventDividers(e){e.save(),e.lineWidth=1;for(const t of this.eventDividers.keys()){e.strokeStyle=t;for(const r of this.eventDividers.get(t)||[]){e.beginPath();const t=this.timeToPosition(r);e.moveTo(t,0),e.lineTo(t,this.offsetHeight)}e.stroke()}e.restore()}getBarHeight(e){const t=Kt;switch(e){case t.Connecting:case t.SSL:case t.DNS:case t.Proxy:case t.Blocking:case t.Push:case t.Queueing:return 7;default:return 13}}getSimplifiedBarRange(e,t){const r=this.offsetWidth-this.leftPadding,i=this.calculator.computeBarGraphPercentages(e);return{start:this.leftPadding+Math.floor(i.start/100*r)+t,mid:this.leftPadding+Math.floor(i.middle/100*r)+t,end:this.leftPadding+Math.floor(i.end/100*r)+t}}buildSimplifiedBarLayers(e,t,r){const i=t.request();if(!i)return;const o=.5,n=this.getSimplifiedBarRange(i,o),s=this.getBarHeight();r+=Math.floor(this.rowHeight/2-s/2+1)-.5;const a=this.styleForWaitingResourceType.get(i.resourceType());this.pathForStyle.get(a).rect(n.start,r,n.mid-n.start,s-1);const l=Math.max(2,n.end-n.mid),d=this.styleForDownloadingResourceType.get(i.resourceType());this.pathForStyle.get(d).rect(n.mid,r,l,s-1);let c=null;if(t.hovered()){c=this.calculator.computeBarGraphLabels(i);const t=10,a=e.measureText(c.left).width,d=e.measureText(c.right).width,h=this.pathForStyle.get(this.hoverDetailsStyle);if(a<n.mid-n.start){const e=n.start+(n.mid-n.start-a)/2;this.textLayers.push({text:c.left,x:e,y:r+this.fontSize})}else t+a+this.leftPadding<n.start&&(this.textLayers.push({text:c.left,x:n.start-a-t-1,y:r+this.fontSize}),h.moveTo(n.start-t,r+Math.floor(s/2)),h.arc(n.start,r+Math.floor(s/2),2,0,2*Math.PI),h.moveTo(n.start-t,r+Math.floor(s/2)),h.lineTo(n.start,r+Math.floor(s/2)));const u=n.mid+l+o;if(d<u-n.mid){const e=n.mid+(u-n.mid-d)/2;this.textLayers.push({text:c.right,x:e,y:r+this.fontSize})}else u+t+d<this.offsetWidth-this.leftPadding&&(this.textLayers.push({text:c.right,x:u+t+1,y:r+this.fontSize}),h.moveTo(u,r+Math.floor(s/2)),h.arc(u,r+Math.floor(s/2),2,0,2*Math.PI),h.moveTo(u,r+Math.floor(s/2)),h.lineTo(u+t,r+Math.floor(s/2)))}if(!this.calculator.startAtZero){const t=jt.calculateRequestTimeRanges(i,0).find((e=>e.name===Kt.Total)),a=c?e.measureText(c.left).width:0,l=a<n.mid-n.start,d=13,h=c&&!l?a+d:0,u=this.timeToPosition(t.start);if(n.start-h>u){const e=this.pathForStyle.get(this.wiskerStyle);e.moveTo(u,r+Math.floor(s/2)),e.lineTo(n.start-h,r+Math.floor(s/2));const t=s/2;e.moveTo(u+o,r+t/2),e.lineTo(u+o,r+s-t/2-1)}}}buildTimingBarLayers(e,t){const r=e.request();if(!r)return;const i=jt.calculateRequestTimeRanges(r,0);let o=0;for(const e of i){if(e.name===Kt.Total||e.name===Kt.Sending||e.end-e.start==0)continue;const r=this.styleForTimeRangeName.get(e.name),i=this.pathForStyle.get(r),n=r.lineWidth||0,s=this.getBarHeight(e.name),a=t+Math.floor(this.rowHeight/2-s/2)+n/2,l=this.timeToPosition(e.start),d=this.timeToPosition(e.end);i.rect(l+1*o,a,d-l,s-n),o++}}decorateRow(e,t,r){const i=t.backgroundColor();e.save(),e.beginPath(),e.fillStyle=E.ThemeSupport.instance().getComputedValue(i),e.rect(0,r,this.offsetWidth,this.rowHeight),e.fill(),e.restore()}}var Ur=Object.freeze({__proto__:null,NetworkWaterfallColumn:Mr});const Nr={networkLog:"Network Log",waterfall:"Waterfall",responseHeaders:"Response Headers",manageHeaderColumns:"Manage Header Columns…",startTime:"Start Time",responseTime:"Response Time",endTime:"End Time",totalDuration:"Total Duration",latency:"Latency",name:"Name",path:"Path",url:"Url",method:"Method",status:"Status",text:"Text",protocol:"Protocol",scheme:"Scheme",domain:"Domain",remoteAddress:"Remote Address",type:"Type",initiator:"Initiator",initiatorAddressSpace:"Initiator Address Space",cookies:"Cookies",setCookies:"Set Cookies",size:"Size",content:"Content",time:"Time",priority:"Priority",connectionId:"Connection ID",remoteAddressSpace:"Remote Address Space"},Ar=r.i18n.registerUIStrings("panels/network/NetworkLogViewColumns.ts",Nr),Br=r.i18n.getLocalizedString.bind(void 0,Ar),Vr=r.i18n.getLazilyComputedLocalizedString.bind(void 0,Ar);class Wr{networkLogView;persistantSettings;networkLogLargeRowsSetting;eventDividers;eventDividersShown;gridMode;columns;waterfallRequestsAreStale;waterfallScrollerWidthIsStale;popupLinkifier;calculatorsMap;lastWheelTime;dataGridInternal;splitWidget;waterfallColumn;activeScroller;dataGridScroller;waterfallScroller;waterfallScrollerContent;waterfallHeaderElement;waterfallColumnSortIcon;activeWaterfallSortId;popoverHelper;hasScrollerTouchStarted;scrollerTouchStartPos;constructor(t,r,i,o){this.networkLogView=t,this.persistantSettings=e.Settings.Settings.instance().createSetting("networkLogColumns",{}),this.networkLogLargeRowsSetting=o,this.networkLogLargeRowsSetting.addChangeListener(this.updateRowsSize,this),this.eventDividers=new Map,this.eventDividersShown=!1,this.gridMode=!0,this.columns=[],this.waterfallRequestsAreStale=!1,this.waterfallScrollerWidthIsStale=!0,this.popupLinkifier=new w.Linkifier.Linkifier,this.calculatorsMap=new Map,this.calculatorsMap.set(Dr.Time,r),this.calculatorsMap.set(Dr.Duration,i),this.lastWheelTime=0,this.setupDataGrid(),this.setupWaterfall(),E.ThemeSupport.instance().addEventListener(E.ThemeChangeEvent.eventName,(()=>{this.scheduleRefresh()}))}static convertToDataGridDescriptor(e){const t=e.title instanceof Function?e.title():e.title;return{id:e.id,title:t,sortable:e.sortable,align:e.align,nonSelectable:e.nonSelectable,weight:e.weight,allowInSortByEvenWhenHidden:e.allowInSortByEvenWhenHidden}}wasShown(){this.updateRowsSize()}willHide(){this.popoverHelper&&this.popoverHelper.hidePopover()}reset(){this.popoverHelper&&this.popoverHelper.hidePopover(),this.eventDividers.clear()}setupDataGrid(){const e=zr,t=Gr;this.columns=[];for(const r of e){const e=Object.assign({},t,r);if(e.id=e.id,e.subtitle){const t=e.title instanceof Function?e.title():e.title,r=e.subtitle instanceof Function?e.subtitle():e.subtitle;e.titleDOMFragment=this.makeHeaderFragment(t,r)}this.columns.push(e)}this.loadCustomColumnsAndSettings(),this.popoverHelper=new o.PopoverHelper.PopoverHelper(this.networkLogView.element,this.getPopoverRequest.bind(this)),this.popoverHelper.setHasPadding(!0),this.popoverHelper.setTimeout(300,300),this.dataGridInternal=new a.SortableDataGrid.SortableDataGrid({displayName:Br(Nr.networkLog),columns:this.columns.map(Wr.convertToDataGridDescriptor),editCallback:void 0,deleteCallback:void 0,refreshCallback:void 0}),this.dataGridInternal.element.addEventListener("mousedown",(e=>{!this.dataGridInternal.selectedNode&&e.button&&e.consume()}),!0),this.dataGridScroller=this.dataGridInternal.scrollContainer,this.updateColumns(),this.dataGridInternal.addEventListener(a.DataGrid.Events.SortingChanged,this.sortHandler,this),this.dataGridInternal.setHeaderContextMenuCallback(this.innerHeaderContextMenu.bind(this)),this.activeWaterfallSortId=jr.StartTime,this.dataGridInternal.markColumnAsSortedBy(Or,a.DataGrid.Order.Ascending),this.splitWidget=new o.SplitWidget.SplitWidget(!0,!0,"networkPanelSplitViewWaterfall",200);const r=this.dataGridInternal.asWidget();r.setMinimumSize(150,0),this.splitWidget.setMainWidget(r)}setupWaterfall(){this.waterfallColumn=new Mr(this.networkLogView.calculator()),this.waterfallColumn.element.addEventListener("contextmenu",function(e){const t=e,r=this.waterfallColumn.getNodeFromPoint(t.offsetX,t.offsetY);if(!r)return;const i=r.request();if(!i)return;const n=new o.ContextMenu.ContextMenu(t);this.networkLogView.handleContextMenuForRequest(n,i),n.show()}.bind(this)),this.waterfallColumn.element.addEventListener("wheel",this.onMouseWheel.bind(this,!1),{passive:!0}),this.waterfallColumn.element.addEventListener("touchstart",this.onTouchStart.bind(this)),this.waterfallColumn.element.addEventListener("touchmove",this.onTouchMove.bind(this)),this.waterfallColumn.element.addEventListener("touchend",this.onTouchEnd.bind(this)),this.dataGridScroller.addEventListener("wheel",this.onMouseWheel.bind(this,!0),!0),this.dataGridScroller.addEventListener("touchstart",this.onTouchStart.bind(this)),this.dataGridScroller.addEventListener("touchmove",this.onTouchMove.bind(this)),this.dataGridScroller.addEventListener("touchend",this.onTouchEnd.bind(this)),this.waterfallScroller=this.waterfallColumn.contentElement.createChild("div","network-waterfall-v-scroll"),this.waterfallScrollerContent=this.waterfallScroller.createChild("div","network-waterfall-v-scroll-content"),this.dataGridInternal.addEventListener(a.DataGrid.Events.PaddingChanged,(()=>{this.waterfallScrollerWidthIsStale=!0,this.syncScrollers()})),this.dataGridInternal.addEventListener(a.ViewportDataGrid.Events.ViewportCalculated,this.redrawWaterfallColumn.bind(this)),this.createWaterfallHeader(),this.waterfallColumn.contentElement.classList.add("network-waterfall-view"),this.waterfallColumn.setMinimumSize(100,0),this.splitWidget.setSidebarWidget(this.waterfallColumn),this.switchViewMode(!1)}onMouseWheel(e,t){e&&t.consume(!0);const r=t,i=Date.now()-this.lastWheelTime<80;this.activeScroller.scrollBy({top:r.deltaY,behavior:i?"auto":"smooth"}),this.syncScrollers(),this.lastWheelTime=Date.now()}onTouchStart(e){const t=e;this.hasScrollerTouchStarted=!0,this.scrollerTouchStartPos=t.changedTouches[0].pageY}onTouchMove(e){if(!this.hasScrollerTouchStarted)return;const t=e.changedTouches[0].pageY,r=this.scrollerTouchStartPos-t;this.activeScroller.scrollBy({top:r,behavior:"auto"}),this.syncScrollers(),this.scrollerTouchStartPos=t}onTouchEnd(){this.hasScrollerTouchStarted=!1}syncScrollers(){this.waterfallColumn.isShowing()&&(this.waterfallScrollerContent.style.height=this.dataGridScroller.scrollHeight-this.dataGridInternal.headerHeight()+"px",this.updateScrollerWidthIfNeeded(),this.dataGridScroller.scrollTop=this.waterfallScroller.scrollTop)}updateScrollerWidthIfNeeded(){this.waterfallScrollerWidthIsStale&&(this.waterfallScrollerWidthIsStale=!1,this.waterfallColumn.setRightPadding(this.waterfallScroller.offsetWidth-this.waterfallScrollerContent.offsetWidth))}redrawWaterfallColumn(){if(!this.waterfallRequestsAreStale)return this.updateScrollerWidthIfNeeded(),void this.waterfallColumn.update(this.activeScroller.scrollTop,this.eventDividersShown?this.eventDividers:void 0);this.syncScrollers();const e=this.networkLogView.flatNodesList();this.waterfallColumn.update(this.activeScroller.scrollTop,this.eventDividers,e)}createWaterfallHeader(){this.waterfallHeaderElement=this.waterfallColumn.contentElement.createChild("div","network-waterfall-header"),this.waterfallHeaderElement.addEventListener("click",function(){const e=a.DataGrid.Order,t="waterfall"===this.dataGridInternal.sortColumnId(),r=this.dataGridInternal.isSortOrderAscending(),i=t&&r?e.Descending:e.Ascending;this.dataGridInternal.markColumnAsSortedBy("waterfall",i),this.sortHandler()}.bind(this)),this.waterfallHeaderElement.addEventListener("contextmenu",(e=>this.innerHeaderContextMenu(new o.ContextMenu.ContextMenu(e))));this.waterfallHeaderElement.createChild("div").textContent=Br(Nr.waterfall),this.waterfallColumnSortIcon=o.Icon.Icon.create("","sort-order-icon"),this.waterfallHeaderElement.createChild("div","sort-order-icon-container").appendChild(this.waterfallColumnSortIcon)}setCalculator(e){this.waterfallColumn.setCalculator(e)}scheduleRefresh(){this.waterfallColumn.scheduleDraw()}updateRowsSize(){const e=Boolean(this.networkLogLargeRowsSetting.get());this.dataGridInternal.element.classList.toggle("small",!e),this.dataGridInternal.scheduleUpdate(),this.waterfallScrollerWidthIsStale=!0,this.waterfallColumn.setRowHeight(e?41:21),this.waterfallScroller.classList.toggle("small",!e),this.waterfallHeaderElement.classList.toggle("small",!e),window.requestAnimationFrame((()=>{this.waterfallColumn.setHeaderHeight(this.waterfallScroller.offsetTop),this.waterfallColumn.scheduleDraw()}))}show(e){this.splitWidget.show(e)}setHidden(e){o.ARIAUtils.setHidden(this.splitWidget.element,e)}dataGrid(){return this.dataGridInternal}sortByCurrentColumn(){this.sortHandler()}sortHandler(){const e=this.dataGridInternal.sortColumnId();if(this.networkLogView.removeAllNodeHighlights(),this.waterfallRequestsAreStale=!0,"waterfall"===e){this.dataGridInternal.sortOrder()===a.DataGrid.Order.Ascending?this.waterfallColumnSortIcon.setIconType("triangle-up"):this.waterfallColumnSortIcon.setIconType("triangle-down");const e=be.RequestPropertyComparator.bind(null,this.activeWaterfallSortId);return this.dataGridInternal.sortNodes(e,!this.dataGridInternal.isSortOrderAscending()),void this.dataGridSortedForTest()}this.waterfallColumnSortIcon.setIconType("");const t=this.columns.find((t=>t.id===e));if(!t||!t.sortingFunction)return;const r=t.sortingFunction;r&&(this.dataGridInternal.sortNodes(r,!this.dataGridInternal.isSortOrderAscending()),this.dataGridSortedForTest())}dataGridSortedForTest(){}updateColumns(){if(!this.dataGridInternal)return;const e=new Set;if(this.gridMode)for(const t of this.columns)t.visible&&e.add(t.id);else{const t=this.columns.find((e=>"path"===e.hideableGroup&&e.visible));t?e.add(t.id):e.add("name")}this.dataGridInternal.setColumnsVisiblity(e)}switchViewMode(e){this.gridMode!==e&&(this.gridMode=e,e?(this.splitWidget.showBoth(),this.activeScroller=this.waterfallScroller,this.waterfallScroller.scrollTop=this.dataGridScroller.scrollTop,this.dataGridInternal.setScrollContainer(this.waterfallScroller)):(this.networkLogView.removeAllNodeHighlights(),this.splitWidget.hideSidebar(),this.activeScroller=this.dataGridScroller,this.dataGridInternal.setScrollContainer(this.dataGridScroller)),this.networkLogView.element.classList.toggle("brief-mode",!e),this.updateColumns(),this.updateRowsSize())}toggleColumnVisibility(e){this.loadCustomColumnsAndSettings(),e.visible=!e.visible,this.saveColumnsSettings(),this.updateColumns()}saveColumnsSettings(){const e={};for(const t of this.columns)e[t.id]={visible:t.visible,title:t.title};this.persistantSettings.set(e)}loadCustomColumnsAndSettings(){const e=this.persistantSettings.get(),t=Object.keys(e);for(const r of t){const t=e[r];let i=this.columns.find((e=>e.id===r));i||(i=this.addCustomHeader(t.title,r)||void 0),i&&i.hideable&&"boolean"==typeof t.visible&&(i.visible=Boolean(t.visible)),i&&"string"==typeof t.title&&(i.title=t.title)}}makeHeaderFragment(e,t){const r=document.createDocumentFragment();o.UIUtils.createTextChild(r,e);const i=r.createChild("div","network-header-subtitle");return o.UIUtils.createTextChild(i,t),r}innerHeaderContextMenu(e){const t=this.columns.filter((e=>e.hideable)),r=t.filter((e=>!e.isResponseHeader)),i=new Map,o=[];for(const e of r)if(e.hideableGroup){const t=e.hideableGroup;let r=i.get(t);r||(r=[],i.set(t,r)),r.push(e)}else o.push(e);for(const t of i.values()){const r=t.filter((e=>e.visible));for(const i of t){const t=1===r.length&&r[0]===i,o=i.title instanceof Function?i.title():i.title;e.headerSection().appendCheckboxItem(o,this.toggleColumnVisibility.bind(this,i),i.visible,t)}e.headerSection().appendSeparator()}for(const t of o){const r=t.title instanceof Function?t.title():t.title;e.headerSection().appendCheckboxItem(r,this.toggleColumnVisibility.bind(this,t),t.visible)}const n=e.footerSection().appendSubMenuItem(Br(Nr.responseHeaders)),s=t.filter((e=>e.isResponseHeader));for(const e of s){const t=e.title instanceof Function?e.title():e.title;n.defaultSection().appendCheckboxItem(t,this.toggleColumnVisibility.bind(this,e),e.visible)}n.footerSection().appendItem(Br(Nr.manageHeaderColumns),this.manageCustomHeaderDialog.bind(this));const l=jr,d=e.footerSection().appendSubMenuItem(Br(Nr.waterfall));function c(e){let t=this.calculatorsMap.get(Dr.Time);const r=jr;e!==r.Duration&&e!==r.Latency||(t=this.calculatorsMap.get(Dr.Duration)),this.networkLogView.setCalculator(t),this.activeWaterfallSortId=e,this.dataGridInternal.markColumnAsSortedBy("waterfall",a.DataGrid.Order.Ascending),this.sortHandler()}d.defaultSection().appendCheckboxItem(Br(Nr.startTime),c.bind(this,l.StartTime),this.activeWaterfallSortId===l.StartTime),d.defaultSection().appendCheckboxItem(Br(Nr.responseTime),c.bind(this,l.ResponseTime),this.activeWaterfallSortId===l.ResponseTime),d.defaultSection().appendCheckboxItem(Br(Nr.endTime),c.bind(this,l.EndTime),this.activeWaterfallSortId===l.EndTime),d.defaultSection().appendCheckboxItem(Br(Nr.totalDuration),c.bind(this,l.Duration),this.activeWaterfallSortId===l.Duration),d.defaultSection().appendCheckboxItem(Br(Nr.latency),c.bind(this,l.Latency),this.activeWaterfallSortId===l.Latency)}manageCustomHeaderDialog(){const e=[];for(const t of this.columns){const r=t.title instanceof Function?t.title():t.title;t.isResponseHeader&&e.push({title:r,editable:t.isCustomHeader})}const t=new Tr(e,(e=>Boolean(this.addCustomHeader(e))),this.changeCustomHeader.bind(this),this.removeCustomHeader.bind(this)),r=new o.Dialog.Dialog;t.show(r.contentElement),r.setSizeBehavior("MeasureContent"),r.show(this.networkLogView.element)}removeCustomHeader(e){e=e.toLowerCase();const t=this.columns.findIndex((t=>t.id===e));return-1!==t&&(this.columns.splice(t,1),this.dataGridInternal.removeColumn(e),this.saveColumnsSettings(),this.updateColumns(),!0)}addCustomHeader(e,t,r){t||(t=e.toLowerCase()),void 0===r&&(r=this.columns.length-1);const i=this.columns.find((e=>e.id===t));if(i)return null;const o=Object.assign({},Gr,{id:t,title:e,isResponseHeader:!0,isCustomHeader:!0,visible:!0,sortingFunction:be.ResponseHeaderStringComparator.bind(null,t)});return this.columns.splice(r,0,o),this.dataGridInternal&&this.dataGridInternal.addColumn(Wr.convertToDataGridDescriptor(o),r),this.saveColumnsSettings(),this.updateColumns(),o}changeCustomHeader(e,t,r){r||(r=t.toLowerCase()),e=e.toLowerCase();const i=this.columns.findIndex((t=>t.id===e)),o=this.columns[i],n=this.columns.find((e=>e.id===r));return!(!o||n&&e!==r)&&(this.removeCustomHeader(e),this.addCustomHeader(t,r,i),!0)}getPopoverRequest(e){if(!this.gridMode)return null;const t=this.networkLogView.hoveredNode();if(!t||!e.target)return null;const r=e.target.enclosingNodeOrSelfWithClass("network-script-initiated");if(!r)return null;const i=t.request();return i?{box:r.boxInWindow(),show:async e=>{this.popupLinkifier.setLiveLocationUpdateCallback((()=>{e.setSizeBehavior("MeasureContent")}));const t=tt.createStackTracePreview(i,this.popupLinkifier,!1);return!!t&&(e.contentElement.appendChild(t.element),!0)},hide:this.popupLinkifier.reset.bind(this.popupLinkifier)}:null}addEventDividers(e,t){let r="transparent";switch(t){case"network-dcl-divider":r="#0867CB";break;case"network-load-divider":r="#B31412";break;default:return}const i=this.eventDividers.get(r)||[];this.eventDividers.set(r,i.concat(e)),this.networkLogView.scheduleRefresh()}hideEventDividers(){this.eventDividersShown=!0,this.redrawWaterfallColumn()}showEventDividers(){this.eventDividersShown=!1,this.redrawWaterfallColumn()}selectFilmStripFrame(e){this.eventDividers.set(_r,[e]),this.redrawWaterfallColumn()}clearFilmStripFrame(){this.eventDividers.delete(_r),this.redrawWaterfallColumn()}}const Or="waterfall";var Dr;!function(e){e.Duration="Duration",e.Time="Time"}(Dr||(Dr={}));const Gr={subtitle:null,visible:!1,weight:6,sortable:!0,hideable:!0,hideableGroup:null,nonSelectable:!1,isResponseHeader:!1,isCustomHeader:!1,allowInSortByEvenWhenHidden:!1},zr=[{id:"name",title:Vr(Nr.name),subtitle:Vr(Nr.path),visible:!0,weight:20,hideable:!0,hideableGroup:"path",sortingFunction:be.NameComparator},{id:"path",title:Vr(Nr.path),hideable:!0,hideableGroup:"path",sortingFunction:be.RequestPropertyComparator.bind(null,"pathname")},{id:"url",title:Vr(Nr.url),hideable:!0,hideableGroup:"path",sortingFunction:be.RequestURLComparator},{id:"method",title:Vr(Nr.method),sortingFunction:be.RequestPropertyComparator.bind(null,"requestMethod")},{id:"status",title:Vr(Nr.status),visible:!0,subtitle:Vr(Nr.text),sortingFunction:be.RequestPropertyComparator.bind(null,"statusCode")},{id:"protocol",title:Vr(Nr.protocol),sortingFunction:be.RequestPropertyComparator.bind(null,"protocol")},{id:"scheme",title:Vr(Nr.scheme),sortingFunction:be.RequestPropertyComparator.bind(null,"scheme")},{id:"domain",title:Vr(Nr.domain),sortingFunction:be.RequestPropertyComparator.bind(null,"domain")},{id:"remoteaddress",title:Vr(Nr.remoteAddress),weight:10,align:a.DataGrid.Align.Right,sortingFunction:be.RemoteAddressComparator},{id:"remoteaddress-space",title:Vr(Nr.remoteAddressSpace),visible:!1,weight:10,sortingFunction:be.RemoteAddressSpaceComparator},{id:"type",title:Vr(Nr.type),visible:!0,sortingFunction:be.TypeComparator},{id:"initiator",title:Vr(Nr.initiator),visible:!0,weight:10,sortingFunction:be.InitiatorComparator},{id:"initiator-address-space",title:Vr(Nr.initiatorAddressSpace),visible:!1,weight:10,sortingFunction:be.InitiatorAddressSpaceComparator},{id:"cookies",title:Vr(Nr.cookies),align:a.DataGrid.Align.Right,sortingFunction:be.RequestCookiesCountComparator},{id:"setcookies",title:Vr(Nr.setCookies),align:a.DataGrid.Align.Right,sortingFunction:be.ResponseCookiesCountComparator},{id:"size",title:Vr(Nr.size),visible:!0,subtitle:Vr(Nr.content),align:a.DataGrid.Align.Right,sortingFunction:be.SizeComparator},{id:"time",title:Vr(Nr.time),visible:!0,subtitle:Vr(Nr.latency),align:a.DataGrid.Align.Right,sortingFunction:be.RequestPropertyComparator.bind(null,"duration")},{id:"priority",title:Vr(Nr.priority),sortingFunction:be.PriorityComparator},{id:"connectionid",title:Vr(Nr.connectionId),sortingFunction:be.RequestPropertyComparator.bind(null,"connectionId")},{id:"cache-control",isResponseHeader:!0,title:r.i18n.lockedLazyString("Cache-Control"),sortingFunction:be.ResponseHeaderStringComparator.bind(null,"cache-control")},{id:"connection",isResponseHeader:!0,title:r.i18n.lockedLazyString("Connection"),sortingFunction:be.ResponseHeaderStringComparator.bind(null,"connection")},{id:"content-encoding",isResponseHeader:!0,title:r.i18n.lockedLazyString("Content-Encoding"),sortingFunction:be.ResponseHeaderStringComparator.bind(null,"content-encoding")},{id:"content-length",isResponseHeader:!0,title:r.i18n.lockedLazyString("Content-Length"),align:a.DataGrid.Align.Right,sortingFunction:be.ResponseHeaderNumberComparator.bind(null,"content-length")},{id:"etag",isResponseHeader:!0,title:r.i18n.lockedLazyString("ETag"),sortingFunction:be.ResponseHeaderStringComparator.bind(null,"etag")},{id:"keep-alive",isResponseHeader:!0,title:r.i18n.lockedLazyString("Keep-Alive"),sortingFunction:be.ResponseHeaderStringComparator.bind(null,"keep-alive")},{id:"last-modified",isResponseHeader:!0,title:r.i18n.lockedLazyString("Last-Modified"),sortingFunction:be.ResponseHeaderDateComparator.bind(null,"last-modified")},{id:"server",isResponseHeader:!0,title:r.i18n.lockedLazyString("Server"),sortingFunction:be.ResponseHeaderStringComparator.bind(null,"server")},{id:"vary",isResponseHeader:!0,title:r.i18n.lockedLazyString("Vary"),sortingFunction:be.ResponseHeaderStringComparator.bind(null,"vary")},{id:"waterfall",title:Vr(Nr.waterfall),visible:!1,hideable:!1,allowInSortByEvenWhenHidden:!0}],_r="#fccc49";var jr;!function(e){e.StartTime="startTime",e.ResponseTime="responseReceivedTime",e.EndTime="endTime",e.Duration="duration",e.Latency="latency"}(jr||(jr={}));var Kr=Object.freeze({__proto__:null,NetworkLogViewColumns:Wr,_initialSortColumn:Or,get _calculatorTypes(){return Dr},_defaultColumnConfig:Gr,_filmStripDividerColor:_r,get WaterfallSortIds(){return jr}});const $r={invertFilter:"Invert",invertsFilter:"Inverts the search filter",hideDataUrls:"Hide data URLs",hidesDataAndBlobUrls:"Hides data: and blob: URLs",resourceTypesToInclude:"Resource types to include",hasBlockedCookies:"Has blocked cookies",onlyShowRequestsWithBlocked:"Only show requests with blocked response cookies",blockedRequests:"Blocked Requests",onlyShowBlockedRequests:"Only show blocked requests",thirdParty:"3rd-party requests",onlyShowThirdPartyRequests:"Shows only requests with origin different from page origin",dropHarFilesHere:"Drop HAR files here",recordingNetworkActivity:"Recording network activity…",performARequestOrHitSToRecordThe:"Perform a request or hit {PH1} to record the reload.",recordToDisplayNetworkActivity:"Record network log ({PH1}) to display network activity.",learnMore:"Learn more",networkDataAvailable:"Network Data Available",sSRequests:"{PH1} / {PH2} requests",sSTransferred:"{PH1} / {PH2} transferred",sBSBTransferredOverNetwork:"{PH1} B / {PH2} B transferred over network",sSResources:"{PH1} / {PH2} resources",sBSBResourcesLoadedByThePage:"{PH1} B / {PH2} B resources loaded by the page",sRequests:"{PH1} requests",sTransferred:"{PH1} transferred",sBTransferredOverNetwork:"{PH1} B transferred over network",sResources:"{PH1} resources",sBResourcesLoadedByThePage:"{PH1} B resources loaded by the page",finishS:"Finish: {PH1}",domcontentloadedS:"DOMContentLoaded: {PH1}",loadS:"Load: {PH1}",copy:"Copy",copyRequestHeaders:"Copy request headers",copyResponseHeaders:"Copy response headers",copyResponse:"Copy response",copyStacktrace:"Copy stack trace",copyAsPowershell:"Copy as `PowerShell`",copyAsFetch:"Copy as `fetch`",copyAsNodejsFetch:"Copy as `Node.js` `fetch`",copyAsCurlCmd:"Copy as `cURL` (`cmd`)",copyAsCurlBash:"Copy as `cURL` (`bash`)",copyAllAsPowershell:"Copy all as `PowerShell`",copyAllAsFetch:"Copy all as `fetch`",copyAllAsNodejsFetch:"Copy all as `Node.js` `fetch`",copyAllAsCurlCmd:"Copy all as `cURL` (`cmd`)",copyAllAsCurlBash:"Copy all as `cURL` (`bash`)",copyAsCurl:"Copy as `cURL`",copyAllAsCurl:"Copy all as `cURL`",copyAllAsHar:"Copy all as `HAR`",saveAllAsHarWithContent:"Save all as `HAR` with content",clearBrowserCache:"Clear browser cache",clearBrowserCookies:"Clear browser cookies",blockRequestUrl:"Block request URL",unblockS:"Unblock {PH1}",blockRequestDomain:"Block request domain",replayXhr:"Replay XHR",areYouSureYouWantToClearBrowser:"Are you sure you want to clear browser cache?",areYouSureYouWantToClearBrowserCookies:"Are you sure you want to clear browser cookies?",overrideHeaders:"Override headers"},Xr=r.i18n.registerUIStrings("panels/network/NetworkLogView.ts",$r),Jr=r.i18n.getLocalizedString.bind(void 0,Xr),Yr=P.RenderCoordinator.RenderCoordinator.instance();class Qr extends(e.ObjectWrapper.eventMixin(o.Widget.VBox)){networkInvertFilterSetting;networkHideDataURLSetting;networkShowIssuesOnlySetting;networkOnlyBlockedRequestsSetting;networkOnlyThirdPartySetting;networkResourceTypeFiltersSetting;rawRowHeight;progressBarContainer;networkLogLargeRowsSetting;rowHeightInternal;timeCalculatorInternal;durationCalculator;calculatorInternal;columnsInternal;staleRequests;mainRequestLoadTime;mainRequestDOMContentLoadedTime;filters;timeFilter;hoveredNodeInternal;recordingHint;highlightedNode;linkifierInternal;recording;needsRefresh;headerHeightInternal;groupLookups;activeGroupLookup;textFilterUI;invertFilterUI;dataURLFilterUI;resourceCategoryFilterUI;onlyIssuesFilterUI;onlyBlockedRequestsUI;onlyThirdPartyFilterUI;filterParser;suggestionBuilder;dataGrid;summaryToolbarInternal;filterBar;textFilterSetting;constructor(t,r,i){function n(){this.rawRowHeight=Boolean(this.networkLogLargeRowsSetting.get())?41:21,this.rowHeightInternal=this.computeRowHeight()}super(),this.setMinimumSize(50,64),this.element.id="network-container",this.element.classList.add("no-node-selected"),this.networkInvertFilterSetting=e.Settings.Settings.instance().createSetting("networkInvertFilter",!1),this.networkHideDataURLSetting=e.Settings.Settings.instance().createSetting("networkHideDataURL",!1),this.networkShowIssuesOnlySetting=e.Settings.Settings.instance().createSetting("networkShowIssuesOnly",!1),this.networkOnlyBlockedRequestsSetting=e.Settings.Settings.instance().createSetting("networkOnlyBlockedRequests",!1),this.networkOnlyThirdPartySetting=e.Settings.Settings.instance().createSetting("networkOnlyThirdPartySetting",!1),this.networkResourceTypeFiltersSetting=e.Settings.Settings.instance().createSetting("networkResourceTypeFilters",{}),this.rawRowHeight=0,this.progressBarContainer=r,this.networkLogLargeRowsSetting=i,this.networkLogLargeRowsSetting.addChangeListener(n.bind(this),this),this.rawRowHeight=0,this.rowHeightInternal=0,n.call(this),this.timeCalculatorInternal=new Vt,this.durationCalculator=new Wt,this.calculatorInternal=this.timeCalculatorInternal,this.columnsInternal=new Wr(this,this.timeCalculatorInternal,this.durationCalculator,i),this.columnsInternal.show(this.element),this.staleRequests=new Set,this.mainRequestLoadTime=-1,this.mainRequestDOMContentLoadedTime=-1,this.filters=[],this.timeFilter=null,this.hoveredNodeInternal=null,this.recordingHint=null,this.highlightedNode=null,this.linkifierInternal=new w.Linkifier.Linkifier,this.recording=!1,this.needsRefresh=!1,this.headerHeightInternal=0,this.groupLookups=new Map,this.groupLookups.set("Frame",new wr(this)),this.activeGroupLookup=null,this.textFilterUI=new o.FilterBar.TextFilterUI,this.textFilterUI.addEventListener("FilterChanged",this.filterChanged,this),t.addFilter(this.textFilterUI),this.invertFilterUI=new o.FilterBar.CheckboxFilterUI("invert-filter",Jr($r.invertFilter),!0,this.networkInvertFilterSetting),this.invertFilterUI.addEventListener("FilterChanged",this.filterChanged.bind(this),this),o.Tooltip.Tooltip.install(this.invertFilterUI.element(),Jr($r.invertsFilter)),t.addFilter(this.invertFilterUI),this.dataURLFilterUI=new o.FilterBar.CheckboxFilterUI("hide-data-url",Jr($r.hideDataUrls),!0,this.networkHideDataURLSetting),this.dataURLFilterUI.addEventListener("FilterChanged",this.filterChanged.bind(this),this),o.Tooltip.Tooltip.install(this.dataURLFilterUI.element(),Jr($r.hidesDataAndBlobUrls)),t.addFilter(this.dataURLFilterUI);const a=Object.values(e.ResourceType.resourceCategories).map((e=>({name:e.title(),label:()=>e.shortTitle(),title:e.title()})));this.resourceCategoryFilterUI=new o.FilterBar.NamedBitSetFilterUI(a,this.networkResourceTypeFiltersSetting),o.ARIAUtils.setLabel(this.resourceCategoryFilterUI.element(),Jr($r.resourceTypesToInclude)),this.resourceCategoryFilterUI.addEventListener("FilterChanged",this.filterChanged.bind(this),this),t.addFilter(this.resourceCategoryFilterUI),this.onlyIssuesFilterUI=new o.FilterBar.CheckboxFilterUI("only-show-issues",Jr($r.hasBlockedCookies),!0,this.networkShowIssuesOnlySetting),this.onlyIssuesFilterUI.addEventListener("FilterChanged",this.filterChanged.bind(this),this),o.Tooltip.Tooltip.install(this.onlyIssuesFilterUI.element(),Jr($r.onlyShowRequestsWithBlocked)),t.addFilter(this.onlyIssuesFilterUI),this.onlyBlockedRequestsUI=new o.FilterBar.CheckboxFilterUI("only-show-blocked-requests",Jr($r.blockedRequests),!0,this.networkOnlyBlockedRequestsSetting),this.onlyBlockedRequestsUI.addEventListener("FilterChanged",this.filterChanged.bind(this),this),o.Tooltip.Tooltip.install(this.onlyBlockedRequestsUI.element(),Jr($r.onlyShowBlockedRequests)),t.addFilter(this.onlyBlockedRequestsUI),this.onlyThirdPartyFilterUI=new o.FilterBar.CheckboxFilterUI("only-show-third-party",Jr($r.thirdParty),!0,this.networkOnlyThirdPartySetting),this.onlyThirdPartyFilterUI.addEventListener("FilterChanged",this.filterChanged.bind(this),this),o.Tooltip.Tooltip.install(this.onlyThirdPartyFilterUI.element(),Jr($r.onlyShowThirdPartyRequests)),t.addFilter(this.onlyThirdPartyFilterUI),this.filterParser=new I.TextUtils.FilterParser(ii),this.suggestionBuilder=new o.FilterSuggestionBuilder.FilterSuggestionBuilder(ii,Qr.sortSearchValues),this.resetSuggestionBuilder(),this.dataGrid=this.columnsInternal.dataGrid(),this.setupDataGrid(),this.columnsInternal.sortByCurrentColumn(),t.filterButton().addEventListener(o.Toolbar.ToolbarButton.Events.Click,this.dataGrid.scheduleUpdate.bind(this.dataGrid,!0)),this.summaryToolbarInternal=new o.Toolbar.Toolbar("network-summary-bar",this.element),this.summaryToolbarInternal.element.setAttribute("role","status"),new o.DropTarget.DropTarget(this.element,[o.DropTarget.Type.File],Jr($r.dropHarFilesHere),this.handleDrop.bind(this)),e.Settings.Settings.instance().moduleSetting("networkColorCodeResourceTypes").addChangeListener(this.invalidateAllItems.bind(this,!1),this),s.TargetManager.TargetManager.instance().observeModels(s.NetworkManager.NetworkManager,this,{scoped:!0}),u.NetworkLog.NetworkLog.instance().addEventListener(u.NetworkLog.Events.RequestAdded,this.onRequestUpdated,this),u.NetworkLog.NetworkLog.instance().addEventListener(u.NetworkLog.Events.RequestUpdated,this.onRequestUpdated,this),u.NetworkLog.NetworkLog.instance().addEventListener(u.NetworkLog.Events.Reset,this.reset,this),this.updateGroupByFrame(),e.Settings.Settings.instance().moduleSetting("network.group-by-frame").addChangeListener((()=>this.updateGroupByFrame())),this.filterBar=t,this.textFilterSetting=e.Settings.Settings.instance().createSetting("networkTextFilter",""),this.textFilterSetting.get()&&this.textFilterUI.setValue(this.textFilterSetting.get())}updateGroupByFrame(){const t=e.Settings.Settings.instance().moduleSetting("network.group-by-frame").get();this.setGrouping(t?"Frame":null)}static sortSearchValues(e,t){e===g.UIFilter.FilterType.Priority?t.sort(((e,t)=>{const r=m.NetworkPriorities.uiLabelToNetworkPriority(e),i=m.NetworkPriorities.uiLabelToNetworkPriority(t);return m.NetworkPriorities.networkPriorityWeight(r)-m.NetworkPriorities.networkPriorityWeight(i)})):t.sort()}static negativeFilter(e,t){return!e(t)}static requestPathFilter(e,t){return!!e&&e.test(t.path()+"/"+t.name())}static subdomains(e){const t=[e];let r=e.indexOf(".");for(;-1!==r;)t.push("*"+e.substring(r)),r=e.indexOf(".",r+1);return t}static createRequestDomainFilter(e){const t=e.split("*").map(n.StringUtilities.escapeForRegExp).join(".*");return Qr.requestDomainFilter.bind(null,new RegExp("^"+t+"$","i"))}static requestDomainFilter(e,t){return e.test(t.domain)}static runningRequestFilter(e){return!e.finished}static fromCacheRequestFilter(e){return e.cached()}static interceptedByServiceWorkerFilter(e){return e.fetchedViaServiceWorker}static initiatedByServiceWorkerFilter(e){return e.initiatedByServiceWorker()}static requestResponseHeaderFilter(e,t){return void 0!==t.responseHeaderValue(e)}static requestResponseHeaderSetCookieFilter(e,t){return Boolean(t.responseHeaderValue("Set-Cookie")?.includes(e))}static requestMethodFilter(e,t){return t.requestMethod===e}static requestPriorityFilter(e,t){return t.priority()===e}static requestMimeTypeFilter(e,t){return t.mimeType===e}static requestMixedContentFilter(e,t){return e===g.UIFilter.MixedContentFilterValues.Displayed?"optionally-blockable"===t.mixedContentType:e===g.UIFilter.MixedContentFilterValues.Blocked?"blockable"===t.mixedContentType&&t.wasBlocked():e===g.UIFilter.MixedContentFilterValues.BlockOverridden?"blockable"===t.mixedContentType&&!t.wasBlocked():e===g.UIFilter.MixedContentFilterValues.All&&"none"!==t.mixedContentType}static requestSchemeFilter(e,t){return t.scheme===e}static requestCookieDomainFilter(e,t){return t.allCookiesIncludingBlockedOnes().some((t=>t.domain()===e))}static requestCookieNameFilter(e,t){return t.allCookiesIncludingBlockedOnes().some((t=>t.name()===e))}static requestCookiePathFilter(e,t){return t.allCookiesIncludingBlockedOnes().some((t=>t.path()===e))}static requestCookieValueFilter(e,t){return t.allCookiesIncludingBlockedOnes().some((t=>t.value()===e))}static requestSetCookieDomainFilter(e,t){return t.responseCookies.some((t=>t.domain()===e))}static requestSetCookieNameFilter(e,t){return t.responseCookies.some((t=>t.name()===e))}static requestSetCookieValueFilter(e,t){return t.responseCookies.some((t=>t.value()===e))}static requestSizeLargerThanFilter(e,t){return t.transferSize>=e}static statusCodeFilter(e,t){return String(t.statusCode)===e}static getHTTPRequestsFilter(e){return e.parsedURL.isValid&&e.scheme in ri}static resourceTypeFilter(e,t){return t.resourceType().name()===e}static requestUrlFilter(e,t){return new RegExp(n.StringUtilities.escapeForRegExp(e),"i").test(t.url())}static requestTimeFilter(e,t,r){return!(r.issueTime()>t)&&!(-1!==r.endTime&&r.endTime<e)}static copyRequestHeaders(e){t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e.requestHeadersText())}static copyResponseHeaders(e){t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e.responseHeadersText)}static async copyResponse(e){const r=await e.contentData();let i=r.content||"";e.contentType().isTextType()?r.encoded&&i&&(i=window.atob(i)):i=I.ContentProvider.contentAsDataURL(i,e.mimeType,r.encoded),t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(i)}handleDrop(e){const t=e.items;if(!t.length)return;const r=t[0].getAsFile();r&&this.onLoadFromFile(r)}async onLoadFromFile(t){const r=new e.StringOutputStream.StringOutputStream,i=new h.FileUtils.ChunkedFileReader(t,1e7);if(!await i.read(r)){const e=i.error();return void(e&&this.harLoadFailed(e.message))}let o;try{o=new H.HARFormat.HARRoot(JSON.parse(r.data()))}catch(e){return void this.harLoadFailed(e)}u.NetworkLog.NetworkLog.instance().importRequests(H.Importer.Importer.requestsFromHARLog(o.log))}harLoadFailed(t){e.Console.Console.instance().error("Failed to load HAR file with following error: "+t)}setGrouping(e){this.activeGroupLookup&&this.activeGroupLookup.reset();const t=e&&this.groupLookups.get(e)||null;this.activeGroupLookup=t,this.invalidateAllItems()}computeRowHeight(){return Math.round(this.rawRowHeight*window.devicePixelRatio)/window.devicePixelRatio}nodeForRequest(e){return ti.get(e)||null}headerHeight(){return this.headerHeightInternal}setRecording(e){this.recording=e,this.updateSummaryBar()}columns(){return this.columnsInternal}summaryToolbar(){return this.summaryToolbarInternal}modelAdded(e){const t=e.target();if(t.outermostTarget()!==t)return;const r=t.model(s.ResourceTreeModel.ResourceTreeModel);r&&(r.addEventListener(s.ResourceTreeModel.Events.Load,this.loadEventFired,this),r.addEventListener(s.ResourceTreeModel.Events.DOMContentLoaded,this.domContentLoadedEventFired,this));for(const e of u.NetworkLog.NetworkLog.instance().requests())this.isInScope(e)&&this.refreshRequest(e)}modelRemoved(t){const r=t.target();if(r.outermostTarget()!==r)return;const i=r.model(s.ResourceTreeModel.ResourceTreeModel);i&&(i.removeEventListener(s.ResourceTreeModel.Events.Load,this.loadEventFired,this),i.removeEventListener(s.ResourceTreeModel.Events.DOMContentLoaded,this.domContentLoadedEventFired,this));e.Settings.Settings.instance().moduleSetting("network_log.preserve-log").get()||this.reset()}linkifier(){return this.linkifierInternal}setWindow(e,t){e||t?(this.timeFilter=Qr.requestTimeFilter.bind(null,e,t),this.timeCalculatorInternal.setWindow(new Ut(e,t))):(this.timeFilter=null,this.timeCalculatorInternal.setWindow(null)),this.filterRequests()}resetFocus(){this.dataGrid.element.focus()}resetSuggestionBuilder(){this.suggestionBuilder.clear(),this.suggestionBuilder.addItem(g.UIFilter.FilterType.Is,g.UIFilter.IsFilterType.Running),this.suggestionBuilder.addItem(g.UIFilter.FilterType.Is,g.UIFilter.IsFilterType.FromCache),this.suggestionBuilder.addItem(g.UIFilter.FilterType.Is,g.UIFilter.IsFilterType.ServiceWorkerIntercepted),this.suggestionBuilder.addItem(g.UIFilter.FilterType.Is,g.UIFilter.IsFilterType.ServiceWorkerInitiated),this.suggestionBuilder.addItem(g.UIFilter.FilterType.LargerThan,"100"),this.suggestionBuilder.addItem(g.UIFilter.FilterType.LargerThan,"10k"),this.suggestionBuilder.addItem(g.UIFilter.FilterType.LargerThan,"1M"),this.textFilterUI.setSuggestionProvider(this.suggestionBuilder.completions.bind(this.suggestionBuilder))}filterChanged(){this.removeAllNodeHighlights(),this.parseFilterQuery(this.textFilterUI.value(),this.invertFilterUI.checked()),this.filterRequests(),this.textFilterSetting.set(this.textFilterUI.value())}async resetFilter(){this.textFilterUI.clear()}showRecordingHint(){this.hideRecordingHint(),this.recordingHint=this.element.createChild("div","network-status-pane fill");const e=this.recordingHint.createChild("div","recording-hint");if(this.recording){let t=null;const i=o.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction("inspector_main.reload")[0];i&&(t=this.recordingHint.createChild("b"),t.textContent=i.title());e.createChild("span").textContent=Jr($r.recordingNetworkActivity),t&&(e.createChild("br"),e.appendChild(r.i18n.getFormatLocalizedString(Xr,$r.performARequestOrHitSToRecordThe,{PH1:t})))}else{const t=e.createChild("b");t.textContent=o.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction("network.toggle-recording")||"",e.appendChild(r.i18n.getFormatLocalizedString(Xr,$r.recordToDisplayNetworkActivity,{PH1:t}))}e.createChild("br"),e.appendChild(o.XLink.XLink.create("https://developer.chrome.com/docs/devtools/network/?utm_source=devtools&utm_campaign=2019Q1",Jr($r.learnMore))),this.setHidden(!0)}hideRecordingHint(){this.setHidden(!1),this.recordingHint&&this.recordingHint.remove(),o.ARIAUtils.alert(Jr($r.networkDataAvailable)),this.recordingHint=null}setHidden(e){this.columnsInternal.setHidden(e),o.ARIAUtils.setHidden(this.summaryToolbarInternal.element,e)}elementsToRestoreScrollPositionsFor(){return this.dataGrid?[this.dataGrid.scrollContainer]:[]}columnExtensionResolved(){this.invalidateAllItems(!0)}setupDataGrid(){return this.dataGrid.setRowContextMenuCallback(((e,t)=>{const r=t.request();r&&this.handleContextMenuForRequest(e,r)})),this.dataGrid.setStickToBottom(!0),this.dataGrid.setName("networkLog"),this.dataGrid.setResizeMethod(a.DataGrid.ResizeMethod.Last),this.dataGrid.element.classList.add("network-log-grid"),this.dataGrid.element.addEventListener("mousedown",this.dataGridMouseDown.bind(this),!0),this.dataGrid.element.addEventListener("mousemove",this.dataGridMouseMove.bind(this),!0),this.dataGrid.element.addEventListener("mouseleave",(()=>this.setHoveredNode(null)),!0),this.dataGrid.element.addEventListener("keydown",(e=>{if("ArrowRight"===e.key&&this.dataGrid.selectedNode){const e=this.dataGrid.selectedNode.element().querySelector("span.devtools-link");e&&e.focus()}n.KeyboardUtilities.isEnterOrSpaceKey(e)&&(this.dispatchEventToListeners(we.RequestActivated,{showPanel:!0,takeFocus:!0}),e.consume(!0))})),this.dataGrid.element.addEventListener("keyup",(e=>{if(("r"===e.key||"R"===e.key)&&this.dataGrid.selectedNode){const e=this.dataGrid.selectedNode.request();if(!e)return;s.NetworkManager.NetworkManager.canReplayRequest(e)&&s.NetworkManager.NetworkManager.replayRequest(e)}})),this.dataGrid.element.addEventListener("focus",this.onDataGridFocus.bind(this),!0),this.dataGrid.element.addEventListener("blur",this.onDataGridBlur.bind(this),!0),this.dataGrid}dataGridMouseMove(e){const t=e,r=this.dataGrid.dataGridNodeFromNode(t.target),i=t.shiftKey;this.setHoveredNode(r,i)}hoveredNode(){return this.hoveredNodeInternal}setHoveredNode(e,t){this.hoveredNodeInternal&&this.hoveredNodeInternal.setHovered(!1,!1),this.hoveredNodeInternal=e,this.hoveredNodeInternal&&this.hoveredNodeInternal.setHovered(!0,Boolean(t))}dataGridMouseDown(e){const t=e;!this.dataGrid.selectedNode&&t.button&&t.consume()}updateSummaryBar(){this.hideRecordingHint();let t=0,i=0,a=0,l=0,d=0,c=-1,h=-1,p=0;for(const r of u.NetworkLog.NetworkLog.instance().requests()){const o=ti.get(r);if(!o)continue;p++;const n=r.transferSize;t+=n;const u=r.resourceSize;i+=u,ei.has(o)||(a++,l+=n,d+=u);const g=s.NetworkManager.NetworkManager.forRequest(r);g&&r.url()===g.target().inspectedURL()&&r.resourceType()===e.ResourceType.resourceTypes.Document&&g.target().parentTarget()?.type()!==s.Target.Type.Frame&&(c=r.startTime),r.endTime>h&&(h=r.endTime)}if(!p)return void this.showRecordingHint();this.summaryToolbarInternal.removeToolbarItems();const g=(e,t)=>{const r=new o.Toolbar.ToolbarText(e);return r.setTitle(t||e),this.summaryToolbarInternal.appendToolbarItem(r),r.element};if(a!==p?(g(Jr($r.sSRequests,{PH1:a,PH2:p})),this.summaryToolbarInternal.appendSeparator(),g(Jr($r.sSTransferred,{PH1:n.NumberUtilities.bytesToString(l),PH2:n.NumberUtilities.bytesToString(t)}),Jr($r.sBSBTransferredOverNetwork,{PH1:l,PH2:t})),this.summaryToolbarInternal.appendSeparator(),g(Jr($r.sSResources,{PH1:n.NumberUtilities.bytesToString(d),PH2:n.NumberUtilities.bytesToString(i)}),Jr($r.sBSBResourcesLoadedByThePage,{PH1:d,PH2:i}))):(g(Jr($r.sRequests,{PH1:p})),this.summaryToolbarInternal.appendSeparator(),g(Jr($r.sTransferred,{PH1:n.NumberUtilities.bytesToString(t)}),Jr($r.sBTransferredOverNetwork,{PH1:t})),this.summaryToolbarInternal.appendSeparator(),g(Jr($r.sResources,{PH1:n.NumberUtilities.bytesToString(i)}),Jr($r.sBResourcesLoadedByThePage,{PH1:i}))),-1!==c&&-1!==h){if(this.summaryToolbarInternal.appendSeparator(),g(Jr($r.finishS,{PH1:r.TimeUtilities.secondsToString(h-c)})),-1!==this.mainRequestDOMContentLoadedTime&&this.mainRequestDOMContentLoadedTime>c){this.summaryToolbarInternal.appendSeparator();g(Jr($r.domcontentloadedS,{PH1:r.TimeUtilities.secondsToString(this.mainRequestDOMContentLoadedTime-c)})).style.color=`var(${Qr.getDCLEventColor()})`}if(-1!==this.mainRequestLoadTime){this.summaryToolbarInternal.appendSeparator();g(Jr($r.loadS,{PH1:r.TimeUtilities.secondsToString(this.mainRequestLoadTime-c)})).style.color=`var(${Qr.getLoadEventColor()})`}}}scheduleRefresh(){this.needsRefresh||(this.needsRefresh=!0,this.isShowing()&&Yr.write("NetworkLogView.render",this.refresh.bind(this)))}addFilmStripFrames(e){this.columnsInternal.addEventDividers(e,"network-frame-divider")}selectFilmStripFrame(e){this.columnsInternal.selectFilmStripFrame(e)}clearFilmStripFrame(){this.columnsInternal.clearFilmStripFrame()}refreshIfNeeded(){this.needsRefresh&&this.refresh()}invalidateAllItems(e){this.staleRequests=new Set(u.NetworkLog.NetworkLog.instance().requests().filter(this.isInScope)),e?this.scheduleRefresh():this.refresh()}timeCalculator(){return this.timeCalculatorInternal}calculator(){return this.calculatorInternal}setCalculator(e){e&&this.calculatorInternal!==e&&(this.calculatorInternal!==e&&(this.calculatorInternal=e,this.columnsInternal.setCalculator(this.calculatorInternal)),this.calculatorInternal.reset(),this.calculatorInternal.startAtZero?this.columnsInternal.hideEventDividers():this.columnsInternal.showEventDividers(),this.invalidateAllItems())}loadEventFired(e){if(!this.recording)return;const t=e.data.loadTime;t&&(this.mainRequestLoadTime=t,this.columnsInternal.addEventDividers([t],"network-load-divider"))}domContentLoadedEventFired(e){if(!this.recording)return;const{data:t}=e;t&&(this.mainRequestDOMContentLoadedTime=t,this.columnsInternal.addEventDividers([t],"network-dcl-divider"))}wasShown(){this.refreshIfNeeded(),this.registerCSSFiles([mr]),this.columnsInternal.wasShown()}willHide(){this.columnsInternal.willHide()}onResize(){this.rowHeightInternal=this.computeRowHeight()}flatNodesList(){return this.dataGrid.rootNode().flatChildren()}onDataGridFocus(){this.dataGrid.element.matches(":focus-visible")&&this.element.classList.add("grid-focused"),this.updateNodeBackground()}onDataGridBlur(){this.element.classList.remove("grid-focused"),this.updateNodeBackground()}updateNodeBackground(){this.dataGrid.selectedNode&&this.dataGrid.selectedNode.updateBackgroundColor()}updateNodeSelectedClass(e){e?this.element.classList.remove("no-node-selected"):this.element.classList.add("no-node-selected")}stylesChanged(){this.columnsInternal.scheduleRefresh()}refresh(){this.needsRefresh=!1,this.removeAllNodeHighlights(),this.timeCalculatorInternal.updateBoundariesForEventTime(this.mainRequestLoadTime),this.durationCalculator.updateBoundariesForEventTime(this.mainRequestLoadTime),this.timeCalculatorInternal.updateBoundariesForEventTime(this.mainRequestDOMContentLoadedTime),this.durationCalculator.updateBoundariesForEventTime(this.mainRequestDOMContentLoadedTime);const e=new Map,t=[],r=new Set;for(;this.staleRequests.size;){const e=this.staleRequests.values().next().value;this.staleRequests.delete(e);let t=ti.get(e);t||(t=this.createNodeForRequest(e)),r.add(t)}for(const i of r){const r=!this.applyFilter(i);r&&i===this.hoveredNodeInternal&&this.setHoveredNode(null),r||t.push(i);const o=i.request();this.timeCalculatorInternal.updateBoundaries(o),this.durationCalculator.updateBoundaries(o);const n=this.parentNodeForInsert(i);if(ei.has(i)===r&&i.parent===n)continue;r?ei.add(i):ei.delete(i);if(i.parent&&(r||i.parent!==n)){let e=i.parent;if(!e)continue;for(e.removeChild(i);e&&!e.hasChildren()&&e.dataGrid&&e.dataGrid.rootNode()!==e;){const t=e.parent;t.removeChild(e),e=t}}n&&!r&&(n.dataGrid||e.has(n)||(e.set(n,this.dataGrid.rootNode()),t.push(n)),e.set(i,n))}for(const t of e.keys())e.get(t).appendChild(t);for(const e of t)e.refresh();this.updateSummaryBar(),e.size&&this.columnsInternal.sortByCurrentColumn(),this.dataGrid.updateInstantly(),this.didRefreshForTest()}didRefreshForTest(){}parentNodeForInsert(e){if(!this.activeGroupLookup)return this.dataGrid.rootNode();const t=this.activeGroupLookup.groupNodeForRequest(e.request());return t||this.dataGrid.rootNode()}reset(){this.dispatchEventToListeners(we.RequestActivated,{showPanel:!1}),this.setHoveredNode(null),this.columnsInternal.reset(),this.timeFilter=null,this.calculatorInternal.reset(),this.timeCalculatorInternal.setWindow(null),this.linkifierInternal.reset(),this.activeGroupLookup&&this.activeGroupLookup.reset(),this.staleRequests.clear(),this.resetSuggestionBuilder(),this.mainRequestLoadTime=-1,this.mainRequestDOMContentLoadedTime=-1,this.dataGrid.rootNode().removeChildren(),this.updateSummaryBar(),this.dataGrid.setStickToBottom(!0),this.scheduleRefresh()}setTextFilterValue(e){this.textFilterUI.setValue(e),this.dataURLFilterUI.setChecked(!1),this.onlyIssuesFilterUI.setChecked(!1),this.onlyBlockedRequestsUI.setChecked(!1),this.resourceCategoryFilterUI.reset()}createNodeForRequest(e){const t=new be(this,e);ti.set(e,t),ei.add(t);for(let t=e.redirectSource();t;t=t.redirectSource())this.refreshRequest(t);return t}isInScope(e){const t=s.NetworkManager.NetworkManager.forRequest(e);return!t||s.TargetManager.TargetManager.instance().isInScope(t)}onRequestUpdated(e){const t=e.data;this.isInScope(t)&&this.refreshRequest(t)}refreshRequest(e){Qr.subdomains(e.domain).forEach(this.suggestionBuilder.addItem.bind(this.suggestionBuilder,g.UIFilter.FilterType.Domain)),this.suggestionBuilder.addItem(g.UIFilter.FilterType.Method,e.requestMethod),this.suggestionBuilder.addItem(g.UIFilter.FilterType.MimeType,e.mimeType),this.suggestionBuilder.addItem(g.UIFilter.FilterType.Scheme,String(e.scheme)),this.suggestionBuilder.addItem(g.UIFilter.FilterType.StatusCode,String(e.statusCode)),this.suggestionBuilder.addItem(g.UIFilter.FilterType.ResourceType,e.resourceType().name()),this.suggestionBuilder.addItem(g.UIFilter.FilterType.Url,e.securityOrigin());const t=e.priority();if(t&&this.suggestionBuilder.addItem(g.UIFilter.FilterType.Priority,m.NetworkPriorities.uiLabelForNetworkPriority(t)),"none"!==e.mixedContentType&&this.suggestionBuilder.addItem(g.UIFilter.FilterType.MixedContent,g.UIFilter.MixedContentFilterValues.All),"optionally-blockable"===e.mixedContentType&&this.suggestionBuilder.addItem(g.UIFilter.FilterType.MixedContent,g.UIFilter.MixedContentFilterValues.Displayed),"blockable"===e.mixedContentType){const t=e.wasBlocked()?g.UIFilter.MixedContentFilterValues.Blocked:g.UIFilter.MixedContentFilterValues.BlockOverridden;this.suggestionBuilder.addItem(g.UIFilter.FilterType.MixedContent,t)}const r=e.responseHeaders;for(const e of r)this.suggestionBuilder.addItem(g.UIFilter.FilterType.HasResponseHeader,e.name),"Set-Cookie"===e.name&&this.suggestionBuilder.addItem(g.UIFilter.FilterType.ResponseHeaderValueSetCookie);for(const t of e.responseCookies)this.suggestionBuilder.addItem(g.UIFilter.FilterType.SetCookieDomain,t.domain()),this.suggestionBuilder.addItem(g.UIFilter.FilterType.SetCookieName,t.name()),this.suggestionBuilder.addItem(g.UIFilter.FilterType.SetCookieValue,t.value());for(const t of e.allCookiesIncludingBlockedOnes())this.suggestionBuilder.addItem(g.UIFilter.FilterType.CookieDomain,t.domain()),this.suggestionBuilder.addItem(g.UIFilter.FilterType.CookieName,t.name()),this.suggestionBuilder.addItem(g.UIFilter.FilterType.CookiePath,t.path()),this.suggestionBuilder.addItem(g.UIFilter.FilterType.CookieValue,t.value());this.staleRequests.add(e),this.scheduleRefresh()}rowHeight(){return this.rowHeightInternal}switchViewMode(e){this.columnsInternal.switchViewMode(e)}handleContextMenuForRequest(e,r){e.appendApplicableItems(r);let i=e.clipboardSection().appendSubMenuItem(Jr($r.copy));const a=i.footerSection();if(r){i.defaultSection().appendItem(o.UIUtils.copyLinkAddressLabel(),t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind(t.InspectorFrontendHost.InspectorFrontendHostInstance,r.contentURL())),r.requestHeadersText()&&i.defaultSection().appendItem(Jr($r.copyRequestHeaders),Qr.copyRequestHeaders.bind(null,r)),r.responseHeadersText&&i.defaultSection().appendItem(Jr($r.copyResponseHeaders),Qr.copyResponseHeaders.bind(null,r)),r.finished&&i.defaultSection().appendItem(Jr($r.copyResponse),Qr.copyResponse.bind(null,r));const e=r.initiator();if(e){const r=e.stack;if(r){const e=Zr(r);""!==e&&i.defaultSection().appendItem(Jr($r.copyStacktrace),(()=>{t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e)}))}}const n=r.isBlobRequest();t.Platform.isWin()?(a.appendItem(Jr($r.copyAsPowershell),this.copyPowerShellCommand.bind(this,r),n),a.appendItem(Jr($r.copyAsFetch),this.copyFetchCall.bind(this,r,0),n),a.appendItem(Jr($r.copyAsNodejsFetch),this.copyFetchCall.bind(this,r,1),n),a.appendItem(Jr($r.copyAsCurlCmd),this.copyCurlCommand.bind(this,r,"win"),n),a.appendItem(Jr($r.copyAsCurlBash),this.copyCurlCommand.bind(this,r,"unix"),n),a.appendItem(Jr($r.copyAllAsPowershell),this.copyAllPowerShellCommand.bind(this)),a.appendItem(Jr($r.copyAllAsFetch),this.copyAllFetchCall.bind(this,0)),a.appendItem(Jr($r.copyAllAsNodejsFetch),this.copyAllFetchCall.bind(this,1)),a.appendItem(Jr($r.copyAllAsCurlCmd),this.copyAllCurlCommand.bind(this,"win")),a.appendItem(Jr($r.copyAllAsCurlBash),this.copyAllCurlCommand.bind(this,"unix"))):(a.appendItem(Jr($r.copyAsPowershell),this.copyPowerShellCommand.bind(this,r),n),a.appendItem(Jr($r.copyAsFetch),this.copyFetchCall.bind(this,r,0),n),a.appendItem(Jr($r.copyAsNodejsFetch),this.copyFetchCall.bind(this,r,1),n),a.appendItem(Jr($r.copyAsCurl),this.copyCurlCommand.bind(this,r,"unix"),n),a.appendItem(Jr($r.copyAllAsPowershell),this.copyAllPowerShellCommand.bind(this)),a.appendItem(Jr($r.copyAllAsFetch),this.copyAllFetchCall.bind(this,0)),a.appendItem(Jr($r.copyAllAsNodejsFetch),this.copyAllFetchCall.bind(this,1)),a.appendItem(Jr($r.copyAllAsCurl),this.copyAllCurlCommand.bind(this,"unix")))}else i=e.clipboardSection().appendSubMenuItem(Jr($r.copy));if(a.appendItem(Jr($r.copyAllAsHar),this.copyAll.bind(this)),e.saveSection().appendItem(Jr($r.saveAllAsHarWithContent),this.exportAll.bind(this)),c.Runtime.experiments.isEnabled(c.Runtime.ExperimentName.HEADER_OVERRIDES)&&e.saveSection().appendItem(Jr($r.overrideHeaders),this.#l.bind(this,r)),e.editSection().appendItem(Jr($r.clearBrowserCache),this.clearBrowserCache.bind(this)),e.editSection().appendItem(Jr($r.clearBrowserCookies),this.clearBrowserCookies.bind(this)),r){const t=20,i=s.NetworkManager.MultitargetNetworkManager.instance();let a=i.blockedPatterns();function l(e){a.push({enabled:!0,url:e}),i.setBlockedPatterns(a),i.setBlockingEnabled(!0),o.ViewManager.ViewManager.instance().showView("network.blocked-urls")}function d(e){a=a.filter((t=>t.url!==e)),i.setBlockedPatterns(a),o.ViewManager.ViewManager.instance().showView("network.blocked-urls")}const c=r.parsedURL.urlWithoutScheme();if(c&&!a.find((e=>e.url===c)))e.debugSection().appendItem(Jr($r.blockRequestUrl),l.bind(null,c));else if(c){const r=n.StringUtilities.trimMiddle(c,t);e.debugSection().appendItem(Jr($r.unblockS,{PH1:r}),d.bind(null,c))}const h=r.parsedURL.domain();if(h&&!a.find((e=>e.url===h)))e.debugSection().appendItem(Jr($r.blockRequestDomain),l.bind(null,h));else if(h){const r=n.StringUtilities.trimMiddle(h,t);e.debugSection().appendItem(Jr($r.unblockS,{PH1:r}),d.bind(null,h))}s.NetworkManager.NetworkManager.canReplayRequest(r)&&e.debugSection().appendItem(Jr($r.replayXhr),s.NetworkManager.NetworkManager.replayRequest.bind(null,r))}}harRequests(){return u.NetworkLog.NetworkLog.instance().requests().filter(Qr.getHTTPRequestsFilter).filter((t=>t.finished||t.resourceType()===e.ResourceType.resourceTypes.WebSocket&&t.responseReceivedTime))}async copyAll(){const e={log:await H.Log.Log.build(this.harRequests())};t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(JSON.stringify(e,null,2))}async copyCurlCommand(e,r){const i=await Qr.generateCurlCommand(e,r);t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(i)}async copyAllCurlCommand(e){const r=await this.generateAllCurlCommand(u.NetworkLog.NetworkLog.instance().requests(),e);t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(r)}async copyFetchCall(e,r){const i=await this.generateFetchCall(e,r);t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(i)}async copyAllFetchCall(e){const r=await this.generateAllFetchCall(u.NetworkLog.NetworkLog.instance().requests(),e);t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(r)}async copyPowerShellCommand(e){const r=await this.generatePowerShellCommand(e);t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(r)}async copyAllPowerShellCommand(){const e=await this.generateAllPowerShellCommand(u.NetworkLog.NetworkLog.instance().requests());t.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e)}async exportAll(){const t=s.TargetManager.TargetManager.instance().scopeTarget();if(!t)return;const r=t.inspectedURL(),i=e.ParsedURL.ParsedURL.fromString(r),n=i?i.host:"network-log",a=new h.FileUtils.FileOutputStream;if(!await a.open(e.ParsedURL.ParsedURL.concatenate(n,".har")))return;const l=new o.ProgressIndicator.ProgressIndicator;this.progressBarContainer.appendChild(l.element),await H.Writer.Writer.write(a,this.harRequests(),l),l.done(),a.close()}async#l(t){const r=g.UIRequestLocation.UIRequestLocation.responseHeaderMatch(t,{name:"",value:""}),i=T.NetworkPersistenceManager.NetworkPersistenceManager.instance();i.project()?(e.Settings.Settings.instance().moduleSetting("persistenceNetworkOverridesEnabled").set(!0),await i.getOrCreateHeadersUISourceCodeFromUrl(t.url()),await e.Revealer.reveal(r)):o.InspectorView.InspectorView.instance().displaySelectOverrideFolderInfobar((async()=>{await x.SourcesNavigator.OverridesNavigatorView.instance().setupNewWorkspace(),await i.getOrCreateHeadersUISourceCodeFromUrl(t.url()),await e.Revealer.reveal(r)}))}clearBrowserCache(){confirm(Jr($r.areYouSureYouWantToClearBrowser))&&s.NetworkManager.MultitargetNetworkManager.instance().clearBrowserCache()}clearBrowserCookies(){confirm(Jr($r.areYouSureYouWantToClearBrowserCookies))&&s.NetworkManager.MultitargetNetworkManager.instance().clearBrowserCookies()}removeAllHighlights(){this.removeAllNodeHighlights()}applyFilter(e){const t=e.request();if(this.timeFilter&&!this.timeFilter(t))return!1;const r=t.resourceType().category().title();if(!this.resourceCategoryFilterUI.accept(r))return!1;if(this.dataURLFilterUI.checked()&&(t.parsedURL.isDataURL()||t.parsedURL.isBlobURL()))return!1;if(this.onlyIssuesFilterUI.checked()&&!S.RelatedIssue.hasIssueOfCategory(t,S.Issue.IssueCategory.Cookie))return!1;if(this.onlyBlockedRequestsUI.checked()&&!t.wasBlocked()&&!t.corsErrorStatus())return!1;if(this.onlyThirdPartyFilterUI.checked()&&t.isSameSite())return!1;for(let e=0;e<this.filters.length;++e)if(!this.filters[e](t))return!1;return!0}isValidUrl(e){try{return new URL(e),!0}catch(e){return!1}}parseFilterQuery(e,t){const r=this.filterParser.parse(e);this.filters=r.map((e=>{const r=e.key,i=e.text||"",o=e.regex;let s;if(r){const e=n.StringUtilities.escapeForRegExp(r+":"+i);s=this.createSpecialFilter(r,i)||Qr.requestPathFilter.bind(null,new RegExp(e,"i"))}else s=e.regex?Qr.requestPathFilter.bind(null,o):this.isValidUrl(i)?Qr.requestUrlFilter.bind(null,i):Qr.requestPathFilter.bind(null,new RegExp(n.StringUtilities.escapeForRegExp(i),"i"));return e.negative&&!t||!e.negative&&t?Qr.negativeFilter.bind(null,s):s}))}createSpecialFilter(e,t){switch(e){case g.UIFilter.FilterType.Domain:return Qr.createRequestDomainFilter(t);case g.UIFilter.FilterType.HasResponseHeader:return Qr.requestResponseHeaderFilter.bind(null,t);case g.UIFilter.FilterType.ResponseHeaderValueSetCookie:return Qr.requestResponseHeaderSetCookieFilter.bind(null,t);case g.UIFilter.FilterType.Is:if(t.toLowerCase()===g.UIFilter.IsFilterType.Running)return Qr.runningRequestFilter;if(t.toLowerCase()===g.UIFilter.IsFilterType.FromCache)return Qr.fromCacheRequestFilter;if(t.toLowerCase()===g.UIFilter.IsFilterType.ServiceWorkerIntercepted)return Qr.interceptedByServiceWorkerFilter;if(t.toLowerCase()===g.UIFilter.IsFilterType.ServiceWorkerInitiated)return Qr.initiatedByServiceWorkerFilter;break;case g.UIFilter.FilterType.LargerThan:return this.createSizeFilter(t.toLowerCase());case g.UIFilter.FilterType.Method:return Qr.requestMethodFilter.bind(null,t);case g.UIFilter.FilterType.MimeType:return Qr.requestMimeTypeFilter.bind(null,t);case g.UIFilter.FilterType.MixedContent:return Qr.requestMixedContentFilter.bind(null,t);case g.UIFilter.FilterType.Scheme:return Qr.requestSchemeFilter.bind(null,t);case g.UIFilter.FilterType.SetCookieDomain:return Qr.requestSetCookieDomainFilter.bind(null,t);case g.UIFilter.FilterType.SetCookieName:return Qr.requestSetCookieNameFilter.bind(null,t);case g.UIFilter.FilterType.SetCookieValue:return Qr.requestSetCookieValueFilter.bind(null,t);case g.UIFilter.FilterType.CookieDomain:return Qr.requestCookieDomainFilter.bind(null,t);case g.UIFilter.FilterType.CookieName:return Qr.requestCookieNameFilter.bind(null,t);case g.UIFilter.FilterType.CookiePath:return Qr.requestCookiePathFilter.bind(null,t);case g.UIFilter.FilterType.CookieValue:return Qr.requestCookieValueFilter.bind(null,t);case g.UIFilter.FilterType.Priority:return Qr.requestPriorityFilter.bind(null,m.NetworkPriorities.uiLabelToNetworkPriority(t));case g.UIFilter.FilterType.StatusCode:return Qr.statusCodeFilter.bind(null,t);case g.UIFilter.FilterType.ResourceType:return Qr.resourceTypeFilter.bind(null,t);case g.UIFilter.FilterType.Url:return Qr.requestUrlFilter.bind(null,t)}return null}createSizeFilter(e){let t=1;e.endsWith("k")?(t=1e3,e=e.substring(0,e.length-1)):e.endsWith("m")&&(t=1e6,e=e.substring(0,e.length-1));const r=Number(e);return isNaN(r)?null:Qr.requestSizeLargerThanFilter.bind(null,r*t)}filterRequests(){this.removeAllHighlights(),this.invalidateAllItems()}reveal(e){this.removeAllNodeHighlights();const t=ti.get(e);return t&&t.dataGrid?(t.parent&&t.parent instanceof fe&&(t.parent.reveal(),t.parent.expand()),t.reveal(),t):null}revealAndHighlightRequest(e){const t=this.reveal(e);t&&this.highlightNode(t)}revealAndHighlightRequestWithId(e){const t=u.NetworkLog.NetworkLog.instance().requestByManagerAndId(e.manager,e.requestId);t&&this.revealAndHighlightRequest(t)}selectRequest(e,t){const{clearFilter:r}=t||{clearFilter:!0};r&&this.setTextFilterValue("");const i=this.reveal(e);i&&i.select()}removeAllNodeHighlights(){this.highlightedNode&&(this.highlightedNode.element().classList.remove("highlighted-row"),this.highlightedNode=null)}highlightNode(e){o.UIUtils.runCSSAnimationOnce(e.element(),"highlighted-row"),this.highlightedNode=e}filterOutBlobRequests(e){return e.filter((e=>!e.isBlobRequest()))}async generateFetchCall(e,t){const r=new Set(["method","path","scheme","version","accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via","user-agent"]),i=new Set(["cookie","authorization"]),o=JSON.stringify(e.url()),n=e.requestHeaders(),s=n.reduce(((e,t)=>{const i=t.name;return r.has(i.toLowerCase())||i.includes(":")||e.append(i,t.value),e}),new Headers),a={};for(const e of s)a[e[0]]=e[1];const l=e.includedRequestCookies().length||n.some((({name:e})=>i.has(e.toLowerCase())))?"include":"omit",d=n.find((({name:e})=>"referer"===e.toLowerCase())),c=d?d.value:void 0,h=e.referrerPolicy()||void 0,u=await e.requestFormData(),p={headers:Object.keys(a).length?a:void 0,referrer:c,referrerPolicy:h,body:u,method:e.requestMethod,mode:"cors"};if(1===t){const e=n.find((e=>"cookie"===e.name.toLowerCase())),t={};delete p.mode,e&&(t.cookie=e.value),c&&(delete p.referrer,t.Referer=c),c&&(delete p.referrerPolicy,t["Referrer-Policy"]=h),Object.keys(t).length&&(p.headers={...a,...t})}else p.credentials=l;return`fetch(${o}, ${JSON.stringify(p,null,2)});`}async generateAllFetchCall(e,t){const r=this.filterOutBlobRequests(e);return(await Promise.all(r.map((e=>this.generateFetchCall(e,t))))).join(" ;\n")}static async generateCurlCommand(e,t){let r=[];const i=new Set(["accept-encoding","host","method","path","scheme","version"]);const o="win"===t?function(e){const t=/[\r\n]/.test(e)?'^"':'"';return t+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/[^a-zA-Z0-9\s_\-:=+~'\/.',?;()*`&]/g,"^$&").replace(/%(?=[a-zA-Z0-9_])/g,"%^").replace(/\r?\n/g,"^\n\n")+t}:function(e){return/[\0-\x1F\x7F-\x9F!]|\'/.test(e)?"$'"+e.replace(/\\/g,"\\\\").replace(/\'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\0-\x1F\x7F-\x9F!]/g,(function(e){let t=e.charCodeAt(0).toString(16);for(;t.length<4;)t="0"+t;return"\\u"+t}))+"'":"'"+e+"'"};r.push(o(e.url()).replace(/[[{}\]]/g,"\\$&"));let n="GET";const s=[],a=await e.requestFormData();a&&(s.push("--data-raw "+o(a)),i.add("content-length"),n="POST"),e.requestMethod!==n&&r.push("-X "+o(e.requestMethod));const l=e.requestHeaders();for(let e=0;e<l.length;e++){const t=l[e],n=t.name.replace(/^:/,"");i.has(n.toLowerCase())||(t.value.trim()?r.push("-H "+o(n+": "+t.value)):r.push("-H "+o(n+";")))}return r=r.concat(s),r.push("--compressed"),"insecure"===e.securityState()&&r.push("--insecure"),"curl "+r.join(r.length>=3?"win"===t?" ^\n  ":" \\\n  ":" ")}async generateAllCurlCommand(e,t){const r=this.filterOutBlobRequests(e),i=await Promise.all(r.map((e=>Qr.generateCurlCommand(e,t))));return"win"===t?i.join(" &\r\n"):i.join(" ;\n")}async generatePowerShellCommand(e){const t=[],r=new Set(["host","connection","proxy-connection","content-length","expect","range","content-type","user-agent","cookie"]);function i(e){return'"'+e.replace(/[`\$"]/g,"`$&").replace(/[^\x20-\x7E]/g,(e=>"$([char]"+e.charCodeAt(0)+")"))+'"'}t.push("-Uri "+i(e.url())),"GET"!==e.requestMethod&&t.push("-Method "+i(e.requestMethod));const o=function(e){const t=[],r=e.requestHeaders().find((({name:e})=>"user-agent"===e.toLowerCase()));r&&t.push(`$session.UserAgent = ${i(r.value)}`);for(const r of e.includedRequestCookies()){const e=i(r.name()),o=i(r.value()),n=i(r.domain());t.push(`$session.Cookies.Add((New-Object System.Net.Cookie(${e}, ${o}, "/", ${n})))`)}return t.length?"$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession\n"+t.join("\n")+"\n":null}(e);o&&t.push("-WebSession $session");const n=e.requestHeaders(),s=[];for(const e of n){const t=e.name.replace(/^:/,"");r.has(t.toLowerCase())||s.push(i(t)+"="+i(e.value))}s.length&&t.push("-Headers @{\n"+s.join("\n  ")+"\n}");const a=n.find((({name:e})=>"content-type"===e.toLowerCase()));a&&t.push("-ContentType "+i(a.value));const l=await e.requestFormData();if(l){const e=i(l);/[^\x20-\x7E]/.test(l)?t.push("-Body ([System.Text.Encoding]::UTF8.GetBytes("+e+"))"):t.push("-Body "+e)}return(o||"")+"Invoke-WebRequest -UseBasicParsing "+t.join(t.length>=3?" `\n":" ")}async generateAllPowerShellCommand(e){const t=this.filterOutBlobRequests(e);return(await Promise.all(t.map((e=>this.generatePowerShellCommand(e))))).join(";\r\n")}static getDCLEventColor(){return"--color-syntax-3"}static getLoadEventColor(){return"--color-syntax-1"}}function Zr(e){let t="";for(const r of e.callFrames){t+=`${o.UIUtils.beautifyFunctionName(r.functionName)} @ ${r.url}:${r.lineNumber+1}\n`}return e.parent&&(t+=Zr(e.parent)),t}const ei=new WeakSet,ti=new WeakMap;const ri={http:!0,https:!0,ws:!0,wss:!0},ii=Object.values(g.UIFilter.FilterType);var oi=Object.freeze({__proto__:null,NetworkLogView:Qr,computeStackTraceText:Zr,isRequestFilteredOut:function(e){return ei.has(e)},HTTPSchemas:ri});const ni={url:"URL"},si=r.i18n.registerUIStrings("panels/network/NetworkSearchScope.ts",ni),ai=r.i18n.getLocalizedString.bind(void 0,si);class li{performIndexing(e){queueMicrotask((()=>{e.done()}))}async performSearch(e,t,r,i){const o=[],n=u.NetworkLog.NetworkLog.instance().requests().filter((t=>e.filePathMatchesFileQuery(t.url())));t.setTotalWork(n.length);for(const r of n){const i=this.searchRequest(e,r,t);o.push(i)}const s=(await Promise.all(o)).filter((e=>null!==e));if(t.isCanceled())i(!1);else{for(const e of s.sort(((e,t)=>e.label().localeCompare(t.label()))))e.matchesCount()>0&&r(e);t.done(),i(!0)}}async searchRequest(e,t,r){let i=[];if(t.contentType().isTextType()&&(i=await t.searchInContent(e.query(),!e.ignoreCase(),e.isRegex())),r.isCanceled())return null;const o=[];a(t.url())&&o.push(g.UIRequestLocation.UIRequestLocation.urlMatch(t));for(const e of t.requestHeaders())s(e)&&o.push(g.UIRequestLocation.UIRequestLocation.requestHeaderMatch(t,e));for(const e of t.responseHeaders)s(e)&&o.push(g.UIRequestLocation.UIRequestLocation.responseHeaderMatch(t,e));for(const e of i)o.push(g.UIRequestLocation.UIRequestLocation.bodyMatch(t,e));return r.incrementWorked(),new di(t,o);function s(e){return a(`${e.name}: ${e.value}`)}function a(t){const r=e.ignoreCase()?"i":"",i=e.queries().map((e=>new RegExp(n.StringUtilities.escapeForRegExp(e),r)));let o=0;for(const e of i){const r=t.substr(o).match(e);if(!r||void 0===r.index)return!1;o+=r.index+r[0].length}return!0}}stopSearch(){}}class di{request;locations;constructor(e,t){this.request=e,this.locations=t}matchesCount(){return this.locations.length}label(){return this.request.displayName}description(){const e=this.request.parsedURL;return e?e.urlWithoutScheme():this.request.url()}matchLineContent(e){const t=this.locations[e];if(t.isUrlMatch)return this.request.url();const r=t?.header?.header;return r?r.value:t.searchMatch.lineContent}matchRevealable(e){return this.locations[e]}matchLabel(e){const t=this.locations[e];if(t.isUrlMatch)return ai(ni.url);const r=t?.header?.header;return r?`${r.name}:`:t.searchMatch.lineNumber+1}}var ci=Object.freeze({__proto__:null,NetworkSearchScope:li,NetworkSearchResult:di});const hi=new CSSStyleSheet;hi.replaceSync(":root{--override-network-overview-total:#919191;--override-network-overview-blocking:#858585;--override-network-overview-connecting:#d68100;--override-network-overview-service-worker:#d68100;--override-network-overview-service-worker-respond-with:#00a3a3;--override-network-overview-push:#0099e0;--override-network-overview-proxy:#a1887f;--override-network-overview-dns:#009688;--override-network-overview-ssl:#b52dcd;--override-network-overview-sending:#74979a;--override-network-overview-waiting:#00a846;--override-network-overview-receiving:#0299de;--override-network-overview-queueing:#fff;--network-grid-default-color:rgb(255 255 255/100%);--network-grid-stripe-color:rgb(245 245 245/100%);--network-grid-navigation-color:rgb(221 238 255/100%);--network-grid-hovered-color:rgb(235 242 252/70%);--network-grid-initiator-path-color:rgb(58 217 58/40%);--network-grid-initiated-path-color:rgb(217 58 58/40%);--network-grid-selected-color:#dadce0;--network-grid-focus-selected-color:var(--legacy-selection-bg-color);--network-grid-focus-selected-color-has-error:#fad2cf;--network-grid-from-frame-color:rgb(224 247 250/40%);--network-grid-is-product-color:rgb(255 252 225/60%);--network-frame-divider-color:#fccc49}.-theme-with-dark-background{--network-grid-default-color:rgb(36 36 36/100%);--network-grid-stripe-color:rgb(41 41 41/100%);--network-grid-navigation-color:rgb(221 238 255/100%);--network-grid-hovered-color:rgb(20 37 63/70%);--network-grid-initiator-path-color:rgb(58 217 58/40%);--network-grid-initiated-path-color:rgb(217 58 58/40%);--network-grid-selected-color:#454545;--network-grid-focus-selected-color:var(--legacy-selection-bg-color);--network-grid-focus-selected-color-has-error:#482422;--network-grid-from-frame-color:rgb(224 247 250/40%);--network-grid-is-product-color:rgb(255 252 225/60%)}.network-details-view{background:rgb(203 203 203)}.network-details-view-tall-header{border-top:4px solid var(--color-background-elevation-1)}.network-item-view{display:flex;background:var(--color-background)}.network-item-preview-toolbar{border-top:1px solid var(--color-details-hairline);background-color:var(--color-background-elevation-1)}.resource-timing-view{display:block;margin:6px;color:var(--color-text-primary);overflow:auto;background-color:var(--color-background)}.resource-timing-table{width:100%!important}#network-overview-panel{flex:none;position:relative}#network-overview-container{overflow:hidden;flex:auto;display:flex;flex-direction:column;position:relative;border-bottom:1px solid var(--color-details-hairline)}#network-overview-container canvas{width:100%;height:100%}.resources-dividers-label-bar{background-color:var(--color-background)}#network-overview-grid .resources-dividers-label-bar{pointer-events:auto}.network .network-overview{flex:0 0 60px}.network-overview .resources-dividers-label-bar .resources-divider{background-color:transparent}.network-overview .resources-dividers{z-index:250}.request-view.html iframe{width:100%;height:100%;position:absolute}.network-film-strip{border-bottom:solid 1px var(--color-details-hairline);flex:none!important}.network-film-strip-placeholder{flex-shrink:0}.network-tabbed-pane{background-color:var(--color-background-elevation-1)}.network-settings-pane{flex:none;background-color:var(--color-background-elevation-1)}.network-settings-pane .toolbar{flex:1 1}.network-toolbar-container{display:flex;flex:none}.network-toolbar-container > :first-child{flex:1 1 auto}.panel.network .toolbar{background-color:var(--color-background-elevation-1);border-bottom:var(--legacy-divider-border)}@media (forced-colors: active){.panel.network .toolbar{background-color:canvas}}devtools-request-headers{min-width:360px}\n/*# sourceURL=networkPanel.css */\n");const ui={close:"Close",search:"Search",doNotClearLogOnPageReload:"Do not clear log on page reload / navigation",preserveLog:"Preserve log",disableCacheWhileDevtoolsIsOpen:"Disable cache (while DevTools is open)",disableCache:"Disable cache",networkSettings:"Network settings",showMoreInformationInRequestRows:"Show more information in request rows",useLargeRequestRows:"Use large request rows",showOverviewOfNetworkRequests:"Show overview of network requests",showOverview:"Show overview",groupRequestsByTopLevelRequest:"Group requests by top level request frame",groupByFrame:"Group by frame",captureScreenshotsWhenLoadingA:"Capture screenshots when loading a page",captureScreenshots:"Capture screenshots",importHarFile:"Import `HAR` file...",exportHar:"Export `HAR`...",throttling:"Throttling",hitSToReloadAndCaptureFilmstrip:"Hit {PH1} to reload and capture filmstrip.",revealInNetworkPanel:"Reveal in Network panel",recordingFrames:"Recording frames...",fetchingFrames:"Fetching frames...",moreNetworkConditions:"More network conditions…"},pi=r.i18n.registerUIStrings("panels/network/NetworkPanel.ts",ui),gi=r.i18n.getLocalizedString.bind(void 0,pi);let mi,wi,vi,ki,bi,fi,Ci,Si;class Ti extends o.Panel.Panel{networkLogShowOverviewSetting;networkLogLargeRowsSetting;networkRecordFilmStripSetting;toggleRecordAction;pendingStopTimer;networkItemView;filmStripView;filmStripRecorder;currentRequest;panelToolbar;rightToolbar;filterBar;settingsPane;showSettingsPaneSetting;filmStripPlaceholderElement;overviewPane;networkOverview;overviewPlaceholderElement;calculator;splitWidget;sidebarLocation;progressBarContainer;networkLogView;fileSelectorElement;detailsWidget;closeButtonElement;preserveLogSetting;recordLogSetting;throttlingSelect;displayScreenshotDelay;constructor(t){super("network"),this.displayScreenshotDelay=t,this.networkLogShowOverviewSetting=e.Settings.Settings.instance().createSetting("networkLogShowOverview",!0),this.networkLogLargeRowsSetting=e.Settings.Settings.instance().createSetting("networkLogLargeRows",!1),this.networkRecordFilmStripSetting=e.Settings.Settings.instance().createSetting("networkRecordFilmStripSetting",!1),this.toggleRecordAction=o.ActionRegistry.ActionRegistry.instance().action("network.toggle-recording"),this.networkItemView=null,this.filmStripView=null,this.filmStripRecorder=null,this.currentRequest=null;const r=new o.Widget.VBox,i=r.contentElement.createChild("div","network-toolbar-container");this.panelToolbar=new o.Toolbar.Toolbar("",i),this.panelToolbar.makeWrappable(!0),this.rightToolbar=new o.Toolbar.Toolbar("",i),this.filterBar=new o.FilterBar.FilterBar("networkPanel",!0),this.filterBar.show(r.contentElement),this.filterBar.addEventListener("Changed",this.handleFilterChanged.bind(this)),this.settingsPane=new o.Widget.HBox,this.settingsPane.element.classList.add("network-settings-pane"),this.settingsPane.show(r.contentElement),this.showSettingsPaneSetting=e.Settings.Settings.instance().createSetting("networkShowSettingsToolbar",!1),this.showSettingsPaneSetting.addChangeListener(this.updateSettingsPaneVisibility.bind(this)),this.updateSettingsPaneVisibility(),this.filmStripPlaceholderElement=r.contentElement.createChild("div","network-film-strip-placeholder"),this.overviewPane=new m.TimelineOverviewPane.TimelineOverviewPane("network"),this.overviewPane.addEventListener(m.TimelineOverviewPane.Events.WindowChanged,this.onWindowChanged.bind(this)),this.overviewPane.element.id="network-overview-panel",this.networkOverview=new Ir,this.overviewPane.setOverviewControls([this.networkOverview]),this.overviewPlaceholderElement=r.contentElement.createChild("div"),this.calculator=new Vt,this.splitWidget=new o.SplitWidget.SplitWidget(!0,!1,"networkPanelSplitViewState"),this.splitWidget.hideMain(),this.splitWidget.show(r.contentElement),r.setDefaultFocusedChild(this.filterBar);const a=new o.SplitWidget.SplitWidget(!0,!1,"networkPanelSidebarState",225);a.hideSidebar(),a.enableShowModeSaving(),a.show(this.element),this.sidebarLocation=o.ViewManager.ViewManager.instance().createTabbedLocation((async()=>{o.ViewManager.ViewManager.instance().showView("network"),a.showBoth()}),"network-sidebar",!0);const l=this.sidebarLocation.tabbedPane();l.setMinimumSize(100,25),l.element.classList.add("network-tabbed-pane"),l.element.addEventListener("keydown",(e=>{e.key===n.KeyboardUtilities.ESCAPE_KEY&&(a.hideSidebar(),e.consume())}));const d=new o.Toolbar.ToolbarButton(gi(ui.close),"cross");d.addEventListener(o.Toolbar.ToolbarButton.Events.Click,(()=>a.hideSidebar())),l.rightToolbar().appendToolbarItem(d),a.setSidebarWidget(l),a.setMainWidget(r),a.setDefaultFocusedChild(r),this.setDefaultFocusedChild(a),this.progressBarContainer=document.createElement("div"),this.networkLogView=new Qr(this.filterBar,this.progressBarContainer,this.networkLogLargeRowsSetting),this.splitWidget.setSidebarWidget(this.networkLogView),this.fileSelectorElement=o.UIUtils.createFileSelectorElement(this.networkLogView.onLoadFromFile.bind(this.networkLogView)),r.element.appendChild(this.fileSelectorElement),this.detailsWidget=new o.Widget.VBox,this.detailsWidget.element.classList.add("network-details-view"),this.splitWidget.setMainWidget(this.detailsWidget),this.closeButtonElement=document.createElement("div",{is:"dt-close-button"}),this.closeButtonElement.addEventListener("click",(async()=>{const e=o.ActionRegistry.ActionRegistry.instance().action("network.hide-request-details");e&&await e.execute()}),!1),this.closeButtonElement.style.margin="0 5px",this.networkLogShowOverviewSetting.addChangeListener(this.toggleShowOverview,this),this.networkLogLargeRowsSetting.addChangeListener(this.toggleLargerRequests,this),this.networkRecordFilmStripSetting.addChangeListener(this.toggleRecordFilmStrip,this),this.preserveLogSetting=e.Settings.Settings.instance().moduleSetting("network_log.preserve-log"),this.recordLogSetting=e.Settings.Settings.instance().moduleSetting("network_log.record-log"),this.recordLogSetting.addChangeListener((({data:e})=>this.toggleRecord(e))),this.throttlingSelect=this.createThrottlingConditionsSelect(),this.setupToolbarButtons(a),this.toggleRecord(this.recordLogSetting.get()),this.toggleShowOverview(),this.toggleLargerRequests(),this.toggleRecordFilmStrip(),this.updateUI(),s.TargetManager.TargetManager.instance().addModelListener(s.ResourceTreeModel.ResourceTreeModel,s.ResourceTreeModel.Events.WillReloadPage,this.willReloadPage,this,{scoped:!0}),s.TargetManager.TargetManager.instance().addModelListener(s.ResourceTreeModel.ResourceTreeModel,s.ResourceTreeModel.Events.Load,this.load,this,{scoped:!0}),this.networkLogView.addEventListener(we.RequestSelected,this.onRequestSelected,this),this.networkLogView.addEventListener(we.RequestActivated,this.onRequestActivated,this),u.NetworkLog.NetworkLog.instance().addEventListener(u.NetworkLog.Events.RequestAdded,this.onUpdateRequest,this),u.NetworkLog.NetworkLog.instance().addEventListener(u.NetworkLog.Events.RequestUpdated,this.onUpdateRequest,this),u.NetworkLog.NetworkLog.instance().addEventListener(u.NetworkLog.Events.Reset,this.onNetworkLogReset,this)}static instance(e){return mi&&!e?.forceNew||(mi=new Ti(e?.displayScreenshotDelay??1e3)),mi}static revealAndFilter(e){const t=Ti.instance();let r="";for(const t of e)t.filterType?r+=`${t.filterType}:${t.filterValue} `:r+=`${t.filterValue} `;return t.networkLogView.setTextFilterValue(r),o.ViewManager.ViewManager.instance().showView("network")}static async selectAndShowRequest(e,t,r){const i=Ti.instance();await i.selectAndActivateRequest(e,t,r)}throttlingSelectForTest(){return this.throttlingSelect}onWindowChanged(e){const t=Math.max(this.calculator.minimumBoundary(),e.data.startTime/1e3),r=Math.min(this.calculator.maximumBoundary(),e.data.endTime/1e3);t===this.calculator.minimumBoundary()&&r===this.calculator.maximumBoundary()?this.networkLogView.setWindow(0,0):this.networkLogView.setWindow(t,r)}async searchToggleClick(){const e=o.ActionRegistry.ActionRegistry.instance().action("network.search");e&&await e.execute()}setupToolbarButtons(t){const r=new o.Toolbar.ToolbarToggle(gi(ui.search),"search");function i(){const e=t.showMode()!==o.SplitWidget.ShowMode.OnlyMain;r.setToggled(e),e||r.element.focus()}this.panelToolbar.appendToolbarItem(o.Toolbar.Toolbar.createActionButton(this.toggleRecordAction)),this.panelToolbar.appendToolbarItem(o.Toolbar.Toolbar.createActionButton(o.ActionRegistry.ActionRegistry.instance().action("network.clear"))),this.panelToolbar.appendSeparator(),this.panelToolbar.appendToolbarItem(this.filterBar.filterButton()),i(),t.addEventListener(o.SplitWidget.Events.ShowModeChanged,i),r.addEventListener(o.Toolbar.ToolbarButton.Events.Click,(()=>{this.searchToggleClick()})),this.panelToolbar.appendToolbarItem(r),this.panelToolbar.appendSeparator(),this.panelToolbar.appendToolbarItem(new o.Toolbar.ToolbarSettingCheckbox(this.preserveLogSetting,gi(ui.doNotClearLogOnPageReload),gi(ui.preserveLog))),this.panelToolbar.appendSeparator();const n=new o.Toolbar.ToolbarSettingCheckbox(e.Settings.Settings.instance().moduleSetting("cacheDisabled"),gi(ui.disableCacheWhileDevtoolsIsOpen),gi(ui.disableCache));this.panelToolbar.appendToolbarItem(n),this.panelToolbar.appendToolbarItem(this.throttlingSelect);const s=new k.Icon.Icon;s.data={iconName:"network-settings",color:"var(--icon-default)",width:"20px",height:"20px"};const a=new o.Toolbar.ToolbarButton(gi(ui.moreNetworkConditions),s);a.addEventListener(o.Toolbar.ToolbarButton.Events.Click,(()=>{o.ViewManager.ViewManager.instance().showView("network.config")}),this),this.panelToolbar.appendToolbarItem(a),this.rightToolbar.appendToolbarItem(new o.Toolbar.ToolbarItem(this.progressBarContainer)),this.rightToolbar.appendSeparator(),this.rightToolbar.appendToolbarItem(new o.Toolbar.ToolbarSettingToggle(this.showSettingsPaneSetting,"gear",gi(ui.networkSettings),"gear-filled"));const l=new o.Toolbar.Toolbar("",this.settingsPane.element);l.makeVertical(),l.appendToolbarItem(new o.Toolbar.ToolbarSettingCheckbox(this.networkLogLargeRowsSetting,gi(ui.showMoreInformationInRequestRows),gi(ui.useLargeRequestRows))),l.appendToolbarItem(new o.Toolbar.ToolbarSettingCheckbox(this.networkLogShowOverviewSetting,gi(ui.showOverviewOfNetworkRequests),gi(ui.showOverview)));const d=new o.Toolbar.Toolbar("",this.settingsPane.element);d.makeVertical(),d.appendToolbarItem(new o.Toolbar.ToolbarSettingCheckbox(e.Settings.Settings.instance().moduleSetting("network.group-by-frame"),gi(ui.groupRequestsByTopLevelRequest),gi(ui.groupByFrame))),d.appendToolbarItem(new o.Toolbar.ToolbarSettingCheckbox(this.networkRecordFilmStripSetting,gi(ui.captureScreenshotsWhenLoadingA),gi(ui.captureScreenshots))),this.panelToolbar.appendSeparator();const c=new o.Toolbar.ToolbarButton(gi(ui.importHarFile),"import");c.addEventListener(o.Toolbar.ToolbarButton.Events.Click,(()=>this.fileSelectorElement.click()),this),this.panelToolbar.appendToolbarItem(c);const h=new o.Toolbar.ToolbarButton(gi(ui.exportHar),"download");h.addEventListener(o.Toolbar.ToolbarButton.Events.Click,(e=>{this.networkLogView.exportAll()}),this),this.panelToolbar.appendToolbarItem(h)}updateSettingsPaneVisibility(){this.settingsPane.element.classList.toggle("hidden",!this.showSettingsPaneSetting.get())}createThrottlingConditionsSelect(){const e=new o.Toolbar.ToolbarComboBox(null,gi(ui.throttling));return e.setMaxWidth(160),l.ThrottlingManager.throttlingManager().decorateSelectWithNetworkThrottling(e.selectElement()),e}toggleRecord(e){this.toggleRecordAction.setToggled(e),this.recordLogSetting.get()!==e&&this.recordLogSetting.set(e),this.networkLogView.setRecording(e),!e&&this.filmStripRecorder&&this.filmStripRecorder.stopRecording(this.filmStripAvailable.bind(this))}filmStripAvailable(e){if(!e)return;const t=this.networkLogView.timeCalculator();this.filmStripView&&this.filmStripView.setModel(e,1e3*t.minimumBoundary(),1e3*t.boundarySpan()),this.networkOverview.setFilmStripModel(e);const r=e.frames().map((function(e){return e.timestamp/1e3}));this.networkLogView.addFilmStripFrames(r)}onNetworkLogReset(e){const{clearIfPreserved:t}=e.data;K.reset(),this.preserveLogSetting.get()&&!t||(this.calculator.reset(),this.overviewPane.reset()),this.filmStripView&&this.resetFilmStripView()}willReloadPage(){this.pendingStopTimer&&(clearTimeout(this.pendingStopTimer),delete this.pendingStopTimer),this.isShowing()&&this.filmStripRecorder&&this.filmStripRecorder.startRecording()}load(){this.filmStripRecorder&&this.filmStripRecorder.isRecording()&&(this.pendingStopTimer&&window.clearTimeout(this.pendingStopTimer),this.pendingStopTimer=window.setTimeout(this.stopFilmStripRecording.bind(this),this.displayScreenshotDelay))}stopFilmStripRecording(){this.filmStripRecorder&&this.filmStripRecorder.stopRecording(this.filmStripAvailable.bind(this)),delete this.pendingStopTimer}toggleLargerRequests(){this.updateUI()}toggleShowOverview(){this.networkLogShowOverviewSetting.get()?this.overviewPane.show(this.overviewPlaceholderElement):this.overviewPane.detach(),this.doResize()}toggleRecordFilmStrip(){const e=this.networkRecordFilmStripSetting.get();e&&!this.filmStripRecorder&&(this.filmStripView=new m.FilmStripView.FilmStripView,this.filmStripView.setMode(m.FilmStripView.Modes.FrameBased),this.filmStripView.element.classList.add("network-film-strip"),this.filmStripRecorder=new qi(this.networkLogView.timeCalculator(),this.filmStripView),this.filmStripView.show(this.filmStripPlaceholderElement),this.filmStripView.addEventListener(m.FilmStripView.Events.FrameSelected,this.onFilmFrameSelected,this),this.filmStripView.addEventListener(m.FilmStripView.Events.FrameEnter,this.onFilmFrameEnter,this),this.filmStripView.addEventListener(m.FilmStripView.Events.FrameExit,this.onFilmFrameExit,this),this.resetFilmStripView()),!e&&this.filmStripRecorder&&(this.filmStripView&&this.filmStripView.detach(),this.filmStripView=null,this.filmStripRecorder=null)}resetFilmStripView(){const e=o.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction("inspector_main.reload")[0];this.filmStripView&&(this.filmStripView.reset(),e&&this.filmStripView.setStatusText(gi(ui.hitSToReloadAndCaptureFilmstrip,{PH1:e.title()})))}elementsToRestoreScrollPositionsFor(){return this.networkLogView.elementsToRestoreScrollPositionsFor()}wasShown(){o.Context.Context.instance().setFlavor(Ti,this),this.registerCSSFiles([hi]),t.userMetrics.panelLoaded("network","DevTools.Launch.Network")}willHide(){o.Context.Context.instance().setFlavor(Ti,null)}revealAndHighlightRequest(e){this.hideRequestPanel(),e&&this.networkLogView.revealAndHighlightRequest(e)}revealAndHighlightRequestWithId(e){this.hideRequestPanel(),e&&this.networkLogView.revealAndHighlightRequestWithId(e)}async selectAndActivateRequest(e,t,r){return await o.ViewManager.ViewManager.instance().showView("network"),this.networkLogView.selectRequest(e,r),this.showRequestPanel(t),this.networkItemView}handleFilterChanged(){this.hideRequestPanel()}onRowSizeChanged(){this.updateUI()}onRequestSelected(e){const t=e.data;this.currentRequest=t,this.networkOverview.setHighlightedRequest(t),this.updateNetworkItemView()}onRequestActivated(e){const{showPanel:t,tab:r,takeFocus:i}=e.data;t?this.showRequestPanel(r,i):this.hideRequestPanel()}showRequestPanel(e,t){if(this.splitWidget.showMode()!==o.SplitWidget.ShowMode.Both||e||t){if(this.clearNetworkItemView(),this.currentRequest){const r=this.createNetworkItemView(e);r&&t&&r.focus()}this.updateUI()}}hideRequestPanel(){this.clearNetworkItemView(),this.splitWidget.hideMain(),this.updateUI()}updateNetworkItemView(){this.splitWidget.showMode()===o.SplitWidget.ShowMode.Both&&(this.clearNetworkItemView(),this.createNetworkItemView(),this.updateUI())}clearNetworkItemView(){this.networkItemView&&(this.networkItemView.detach(),this.networkItemView=null)}createNetworkItemView(e){if(this.currentRequest)return this.networkItemView=new pr(this.currentRequest,this.networkLogView.timeCalculator(),e),this.networkItemView.leftToolbar().appendToolbarItem(new o.Toolbar.ToolbarItem(this.closeButtonElement)),this.networkItemView.show(this.detailsWidget.element),this.splitWidget.showBoth(),this.networkItemView}updateUI(){this.detailsWidget&&this.detailsWidget.element.classList.toggle("network-details-view-tall-header",this.networkLogLargeRowsSetting.get()),this.networkLogView&&this.networkLogView.switchViewMode(!this.splitWidget.isResizable())}appendApplicableItems(e,t,r){function i(e){o.ViewManager.ViewManager.instance().showView("network").then(this.networkLogView.resetFilter.bind(this.networkLogView)).then(this.revealAndHighlightRequest.bind(this,e))}function n(e){t.revealSection().appendItem(gi(ui.revealInNetworkPanel),i.bind(this,e))}if(e.target.isSelfOrDescendant(this.element))return;if(r instanceof s.Resource.Resource){const e=r;return void(e.request&&n.call(this,e.request))}if(r instanceof p.UISourceCode.UISourceCode){const e=r,t=h.ResourceUtils.resourceForURL(e.url());return void(t&&t.request&&n.call(this,t.request))}if(!(r instanceof s.NetworkRequest.NetworkRequest))return;const a=r;this.networkItemView&&this.networkItemView.isShowing()&&this.networkItemView.request()===a||n.call(this,a)}onFilmFrameSelected(e){const t=e.data;this.overviewPane.setWindowTimes(0,t)}onFilmFrameEnter(e){const t=e.data;this.networkOverview.selectFilmStripFrame(t),this.networkLogView.selectFilmStripFrame(t/1e3)}onFilmFrameExit(){this.networkOverview.clearFilmStripFrame(),this.networkLogView.clearFilmStripFrame()}onUpdateRequest(e){const t=e.data;this.calculator.updateBoundaries(t),this.overviewPane.setBounds(1e3*this.calculator.minimumBoundary(),1e3*this.calculator.maximumBoundary()),this.networkOverview.updateRequest(t),this.overviewPane.scheduleUpdate()}resolveLocation(e){return"network-sidebar"===e?this.sidebarLocation:null}}class yi{static instance(e={forceNew:null}){const{forceNew:t}=e;return wi&&!t||(wi=new yi),wi}appendApplicableItems(e,t,r){Ti.instance().appendApplicableItems(e,t,r)}}class xi{static instance(e={forceNew:null}){const{forceNew:t}=e;return vi&&!t||(vi=new xi),vi}reveal(e){if(!(e instanceof s.NetworkRequest.NetworkRequest))return Promise.reject(new Error("Internal error: not a network request"));const t=Ti.instance();return o.ViewManager.ViewManager.instance().showView("network").then(t.revealAndHighlightRequest.bind(t,e))}}class Ri{static instance(e={forceNew:null}){const{forceNew:t}=e;return ki&&!t||(ki=new Ri),ki}reveal(e){if(!(e instanceof g.NetworkRequestId.NetworkRequestId))return Promise.reject(new Error("Internal error: not a network request ID"));const t=Ti.instance();return o.ViewManager.ViewManager.instance().showView("network").then(t.revealAndHighlightRequestWithId.bind(t,e))}}class Ii{static instance(e={forceNew:null}){const{forceNew:t}=e;return bi&&!t||(bi=new Ii),bi}reveal(e){return e instanceof g.UIFilter.UIRequestFilter?Ti.revealAndFilter(e.filters):Promise.reject(new Error("Internal error: not a UIRequestFilter"))}}class qi{tracingManager;resourceTreeModel;timeCalculator;filmStripView;tracingModel;callback;constructor(e,t){this.tracingManager=null,this.resourceTreeModel=null,this.timeCalculator=e,this.filmStripView=t,this.tracingModel=null,this.callback=null}traceEventsCollected(e){this.tracingModel&&this.tracingModel.addEvents(e)}tracingComplete(){this.tracingModel&&this.tracingManager&&(this.tracingModel.tracingComplete(),this.tracingManager=null,this.callback&&this.callback(new s.FilmStripModel.FilmStripModel(this.tracingModel,1e3*this.timeCalculator.minimumBoundary())),this.callback=null,this.resourceTreeModel&&this.resourceTreeModel.resumeReload(),this.resourceTreeModel=null)}tracingBufferUsage(){}eventsRetrievalProgress(e){}startRecording(){this.filmStripView.reset(),this.filmStripView.setStatusText(gi(ui.recordingFrames));const e=s.TargetManager.TargetManager.instance().scopeTarget()?.model(s.TracingManager.TracingManager);!this.tracingManager&&e&&(this.tracingManager=e,this.resourceTreeModel=this.tracingManager.target().model(s.ResourceTreeModel.ResourceTreeModel),this.tracingModel=new s.TracingModel.TracingModel,this.tracingManager.start(this,"-*,disabled-by-default-devtools.screenshot",""),t.userMetrics.actionTaken(t.UserMetrics.Action.FilmStripStartedRecording))}isRecording(){return Boolean(this.tracingManager)}stopRecording(e){this.tracingManager&&(this.tracingManager.stop(),this.resourceTreeModel&&this.resourceTreeModel.suspendReload(),this.callback=e,this.filmStripView.setStatusText(gi(ui.fetchingFrames)))}}class Li{static instance(e={forceNew:null}){const{forceNew:t}=e;return fi&&!t||(fi=new Li),fi}handleAction(e,t){const r=o.Context.Context.instance().flavor(Ti);if(console.assert(Boolean(r&&r instanceof Ti)),!r)return!1;switch(t){case"network.toggle-recording":return r.toggleRecord(!r.recordLogSetting.get()),!0;case"network.hide-request-details":return!!r.networkItemView&&(r.hideRequestPanel(),r.networkLogView.resetFocus(),!0);case"network.search":{const e=o.InspectorView.InspectorView.instance().element.window().getSelection();if(!e)return!1;let t="";return e.rangeCount&&(t=e.toString().replace(/\r?\n.*/,"")),Hi.openSearch(t),!0}case"network.clear":return u.NetworkLog.NetworkLog.instance().reset(!0),!0}return!1}}class Fi{static instance(e={forceNew:null}){const{forceNew:t}=e;return Ci&&!t||(Ci=new Fi),Ci}async reveal(e){const t=e,r=await Ti.instance().selectAndActivateRequest(t.request,t.tab,t.filterOptions);r&&(t.searchMatch&&await r.revealResponseBody(t.searchMatch.lineNumber),t.header&&r.revealHeader(t.header.section,t.header.header?.name))}}class Hi extends M.SearchView.SearchView{constructor(){super("network")}static instance(e={forceNew:null}){const{forceNew:t}=e;return Si&&!t||(Si=new Hi),Si}static async openSearch(e,t){await o.ViewManager.ViewManager.instance().showView("network.search-network-tab");const r=Hi.instance();return r.toggle(e,Boolean(t)),r}createScope(){return new li}}var Pi=Object.freeze({__proto__:null,NetworkPanel:Ti,ContextMenuProvider:yi,RequestRevealer:xi,RequestIdRevealer:Ri,NetworkLogWithFilterRevealer:Ii,FilmStripRecorder:qi,ActionDelegate:Li,RequestLocationRevealer:Fi,SearchNetworkView:Hi});export{O as BinaryResourceView,$ as BlockedURLsPane,ie as EventSourceMessagesView,ue as NetworkConfigView,Ce as NetworkDataGridNode,kr as NetworkFrameGrouper,gr as NetworkItemView,oi as NetworkLogView,Kr as NetworkLogViewColumns,yr as NetworkManageCustomHeadersView,Pr as NetworkOverview,Pi as NetworkPanel,ci as NetworkSearchScope,Ot as NetworkTimeCalculator,Ur as NetworkWaterfallColumn,Ie as RequestCookiesView,nt as RequestHTMLView,We as RequestHeadersView,rt as RequestInitiatorView,Xe as RequestPayloadView,Ht as RequestPreviewView,ht as RequestResponseView,Jt as RequestTimingView,dr as ResourceWebSocketFrameView,bt as SignedExchangeInfoView};
